|
Hello
how to make image transparent in Win Appl in c#.NET so that I can see controls behind it,what r the properties that I have to changes for it.
Thanking you
Yogesh_T
|
|
|
|
|
how to map an object of the so called real life to programming world.
Say there is a car. How can we take this to programming world. Car with wheel, engine, etc. Car
can move without even doors, it's movement will be effected if one wheel is with low air pressure.
etc.
Here car should be an object, wheel also an object. Car has wheels, doors etc., but wheel has different
impact than doors as far as motion is concerned.
Can someone help me visualize this object to OOP?
|
|
|
|
|
You can't, not really. Every car has some stains on the seats, are you going to bother to map those ? Chips in the paint ? Oil on the engine ? No. You choose the bits that are important to what you want to write, and you map those to classes. Getting it exactly the way it is in the real world is not the point, mapping the bits you want to interact with so they work smoothly in your program, is.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
>>You can't, not really.
Help me to some extent.
>>Every car has some stains on the seats, are you going to bother to map those ?
Yes, anything with some volume should be able to interact with the seat. There some physics rules should come handy. and so on
>> Chips in the paint ?
Yes, again some interaction with the environment. How environment can effect the car?
>> Oil on the engine ?
Yes, of course. Help me outhere as well.
>> No. You choose the bits that are important to what you want to write, and you map those to classes. Getting it exactly the way it is in the real world is not the point, mapping the bits you want to interact with so they work smoothly in your program, is.
'm want to simulate the max possible.
|
|
|
|
|
sinanju wrote: 'm want to simulate the max possible.
Why ? Are you writing a game ? Why would you care if there's oil ON the engine ( under the hood ), or chips in the paint, or stains in the seat ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
public class Car
{
private Wheel [] wheels;
private Door [] doors;
private SteeringWheel steeringWheel;
private GearBox gearBox;
private Engine engine;
public Car()
{
wheels = new Wheel[4];
doors = new Door[4];
gearBox = new GearBox();
steeringWheel = new SteeringWheel();
engine = new TwoLitreEngine();
}
public void Start()
{
gearBox.SetNeutral();
while(!engine.Started)
{
engine.EngageStarterMotor();
}
engine.DisengageStarterMotor();
}
}
You can go on ad infinitum implementing whatever objects you want to define. The above code relies on an implementation of Wheel , Door , GearBox , and SteeringWheel . Also, a base class called Engine and an implementation of it called TwoLitreEngine is defined.
|
|
|
|
|
Car a is a very large object to map.
This class is a decent basic overview, but due to the massive variations between types of car, you could consider making it abstract and defining specific types of car.
This implementation assumes that a car will have 4 wheels (some had 3), and 4 doors (some have 2), and does the book count as a door? Manual or Auto gearbox, etc.
e.g.
public class VauxhallCorsa : public Car
{
public VauxhallCorsa()
{
wheels = new Wheel[4];
doors = new Door[3];
gearBox = new ManualGearBox();
steeringWheel = new SteeringWheel();
engine = new OneLitreEngine();
}
}
|
|
|
|
|
wheelerbarry wrote: This class is a decent basic overview, but due to the massive variations between types of car, you could consider making it abstract and defining specific types of car.
Considering the OP isnt even proficient in defining objects yet, I tried to stear clear of the obvious abstractions.
Of course, the base class should be called Vehicle allowing definition of a Boat (no wheels, still with engine), Bycycle (2 wheels, no engine/gearbox) etc etc etc.
My answer was simply to give a basic layout of a class, which i think is what the OP asked for!
|
|
|
|
|
Hi,
I am working on a Windows based project using C#.
Using VS 1.1 version.
I am using a datagrid.I have a problem, that if the user
modifies the data in the grid, how will we come to know
that there is a change in value in the grid.
I am not using DataSet...i am using a DataGrid
Plz help me to solve the prob,since i am new to C#
Thanks in advance
Regards,
Vaishali
|
|
|
|
|
how you fill the rows in the grid , what is your data source ??
Tamimi - Code
|
|
|
|
|
hi,
i made a access database and view it on a datagrid, i did this by using the datasource,ea in the toolbar. i can add rows to my database, but i cant find the way to delete one. i can delete one in the datagrid but it is not gone in my database. i tried this code:
try
{
tabel1TableAdapter.Update(db1DataSet.tabel1);
db1DataSet.AcceptChanges();
// refresh after the delete
this.tabel1TableAdapter.Fill(this.db1DataSet.tabel1);
Application.DoEvents();
}
catch (System.Exception ex)
{
db1DataSet.RejectChanges();
lbl_error.Text= ex.Message;
}
but i get an error because there is nog valid delete command,
so i looked that op, now i dont know how to create a deletecommand using the tableadapter that was build by the wizard in the beginning by using the toolbar.
can anybody help, or is there another way to delete items without having an error
thx
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
Hello Everyone,
I've got a little problem that I can't seem to find a straight answer to so I'm throwing it out there for you guys to take a stab at it.
I have a UserControl being developed that has two panel controls.
I have already set the designer attribute to allow child controls at design time
<br />
[DesignerCategoryAttribute("Component")]<br />
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]<br />
[ToolboxBitmap(typeof(XPanel),"Image1.bmp")]<br />
public partial class XPanel : UserControl<br />
now i can drag a control on it as is no problem.
what i need to do is when a control is added send it to one of the internal panel's controls collection.
i've tried using the ControlAdded and ControlRemoved events to accomplish this
<br />
private void XPanel_ControlAdded(object sender, ControlEventArgs e)<br />
{<br />
this.DockingPanel.Controls.Add(e.Control);<br />
}<br />
<br />
private void XPanel_ControlRemoved(object sender, ControlEventArgs e)<br />
{<br />
this.DockingPanel.Controls.Remove(e.Control);<br />
}<br />
when i drag a control on to it now i get a pop up in visual studio that says
'child' is not a child control of this parent
if someone could tell me what i'm doing wrong or what i'm missing it would be greatly appreciated.
Ryan Strope
|
|
|
|
|
Hello,
I think the problem is the ControlRemoved EventHandler.
If you add a Control the code in the ControlAdded EventHandler has the effect, that also the code in ControlRemoved is going to be worked threw.
Maybe the solution is to set a boolean flag in the ControlAdded code.
private bool comesfromdesigner=true;
Try that:
private void XPanel_ControlAdded(object sender, ControlEventArgs e)
{
comesfromdesigner = false;
this.XPanel.Controls.Remove(e.Control);
this.DockingPanel.Controls.Add(e.Control);
comesfromdesigner = true;
}
private void XPanel_ControlRemoved(object sender, ControlEventArgs e)
{
if(comesfromdesigner)
this.DockingPanel.Controls.Remove(e.Control);
}
But I'm not sure if you need the ControlRemove code at all!
All the best,
Martin
|
|
|
|
|
Thanks for the effort but no dice there,
tried that and it still didn't work.
Sorry for the short response on the way into the office
Ryan Strope
|
|
|
|
|
How can i delete a file created by FileStream
sAqIb
|
|
|
|
|
You can delete all files in the same way:
System.IO.File.Delete("path");
When you ask specifically about files created by a FileStream, then I guess you have a problem with the file being locked.
This can happen if an exception occurs while you are working with the filestream, or if you haven't released the file from the stream again before deleting it.
You should always use Structured Exception Handling when using I/O operations in code:
using System;
using System.IO;
namespace Testing
{
public class Test
{
public static void Main()
{
FileStream fs = null;
try
{
fs = new FileStream(@"c:\test.txt", FileMode.Create);
byte[] content = new System.Text.UTF8Encoding(true).GetBytes("Hi there!");
fs.Write(content, 0, 9);
}
catch (IOException ioe)
{
Console.WriteLine("Something happened");
if(fs != null)
fs.Close();
}
}
}
}
In this case the file will always be closed, and you should be able to delete it.
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
Actually, this code won't work. Catch only runs when an exception occurs, I believe you meant to put the fs.Close code in a finally block ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hehe... that's what you get for replying to a forum post before the first cup'o'mocca in the morning
You're right of course
Corrected code reads:
using System;
using System.IO;
namespace Testing{
public class Test
{
public static void Main()
{
FileStream fs = null;
try
{
fs = new FileStream(@"c:\test.txt", FileMode.Create);
byte[] content = new System.Text.UTF8Encoding(true).GetBytes("Hi there!");
fs.Write(content, 0, 9);
}
catch (IOException ioe)
{
Console.WriteLine("Something happened");
}
finally
{
if(fs != null)
fs.Close();
}
}
}
}
Thx for the correction Christian!
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
thanks buddy.
System.IO.File.Delete("path"); worked for me.
sAqIb
|
|
|
|
|
Great!
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
how can i create mobile projects in C#?
|
|
|
|
|
|
Hi,
I want to transfer the file from client to server.
Just using IPadress only, here i dont use asp and web services.
Any one kindly guide me.
|
|
|
|
|