|
|
/nod.
I know about the MemberWiseClone function, but it creates a new copy of the class. Was just hoping to copy over the data from one class to another. Wishing for a function like
object MemberWiseCopy( object )
|
|
|
|
|
er, do you mean like
void MemberWiseCopy(object fromObject, object toObject);
The point being to use an already instanciated object instead of creating a brand new one inside the method?
|
|
|
|
|
Yes, that's exactly what I'm looking for.
Here's my save/undo feature. The function 'copy' is the one that I would like to replace with this 'mythical' function call.
public void Edited( BaseFeature pBaseFeature )
{
UndoFeature pUndoFeature = new UndoFeature( );
pUndoFeature.OldFeature = pBaseFeature.Clone( );
pUndoFeature.NewFeature = pBaseFeature;
pUndoFeature.Action = Actions.Edited;
pUndoFeature.Group = Group;
UndoList.Push( pUndoFeature );
}
public void Undo( ArrayList pFeatures )
{
UndoFeature pUndoFeature = null;
do
{
...
pUndoFeature = (UndoFeature) UndoList.Pop( );
switch( pUndoFeature.Action )
{
...
case Actions.Edited:
pUndoFeature.OldFeature.Invalidate( );
pUndoFeature.NewFeature.Invalidate( );
pUndoFeature.NewFeature.Copy( pUndoFeature.OldFeature );
break;
}
} while( pUndoFeature.Group == true );
}
}
|
|
|
|
|
Hallo!!!
So once again I have a problem....
This time i'm having trouble passing a reference of a form to an object, on the load_form event.
But this just gives me a blank reference....
How can I go around this?
|
|
|
|
|
I'm having trouble understanding what you're trying to do. Please post some code. And by blank do you mean null reference or do you have a watched variable that is showing up blank?
|
|
|
|
|
Well basicly what i've been doing is:
private void Form1_Load(object sender, System.EventArgs e)
{
//initiating a class (declared earlier=
defaultCls = new defaultClass(pictureBox1, form1.aktiveform);
}
//(only an example)
public class default
//construktor
public default(pictureBox pB, form frm)
{
// trying to use the frm reference...
}
Error message:
An unhandled exception of type 'System.NullReferenceException' occurred in CopyImage.exe
Additional information: Object reference not set to an instance of an object.
Well this must mean that the Form1 reference isn't set at this time, musn't it???
It works fine if I do the same, on f.x. a keypress event....
What I really was wondering about is if theres an event, which occurs after load complete.
f.x. OnLoadComplete(), or something like that????
|
|
|
|
|
I re-created what you gave me the best I could and it worked. I could not get any null reference exceptions.
The only thing I don't get is why your passing ActiveForm (assuming thats what you mean by "aktiveform") which may or may not actually be the form you want to reference.
|
|
|
|
|
So you are able to send a reference to an object (done when the OnLoad event occurs), and then use it in the object...
To be more precise, I tried to get the window location by saying:
//the frm = reference of Form1.AktiveForm
frmX = frm.Location.X
But that just throws an exception...
Ok so the problem could be that I'm sending the Form1.AktiveForm, you say... Yes that sound very likely because noone says that the form is Aktive (or in focus) at this time....
Then you said that you can't se the logic in me sending Form1.AktiveForm.... What shoudl I be sending???
If I try just to send Form1, the debugger says soemthing about a variable was expected????
...... so any ideas??? >
|
|
|
|
|
Heh....ehh... ups.... all I had to do was send a "this" pointer instead.... dooh.
Well I'm still new at c#, so I have an excuse
Anyway, thanks!!!
|
|
|
|
|
Hi,
I have a main window which is a MdiParent and to which i pop up a couple of other windows (on some event) as mdiChild using the show() method. I want each child window to appear at a particular position for which i use DockStyle properties.
But the new window which opens up resizes itself to the height or width of the original window depending on the dockstyle. I want the size of the mdichild form to remain as it is. What property should i set for this.
Also, In case there are more than one window which pops up,when i change the control from one window to another the position of the window changes. How to avoid this??
Thanks
Sripriya
|
|
|
|
|
simply setting the Location property doesn't work?
:wq
|
|
|
|
|
1.Choose "Microsoft OLE DB Provider for ODBC Drivers"
2.Choose "Use data source name" and select a alias from drop list.( The alias has no password)
3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".
Thank you for your help!
I'm amumu, and you?
|
|
|
|
|
You have three options:
- If you're connecting to SQL Server, you could use the SQLConnection and related objects in the System.Data.SqlClient namespace;
- If you really need an OLEDB connection, use the OLE DB Provider for SQL Server (SQLOLEDB.1), or the equivalent for your data source;
- If you absolutely must have an ODBC connection, you need to download the ODBC provider for .Net and use that instead;
|
|
|
|
|
Thank you.
But I think the oleDbConnection should work properly when I do the steps as above, why does it reports error?
I'm amumu, and you?
|
|
|
|
|
The objects in System.Data.OleDb do not support ODBC connections, so you can't use the OLE DB Provider for ODBC. You have to use the ODBC .Net Provider to access an ODBC data source.
|
|
|
|
|
if u just wanna use access like me, just use a JET OLE DB connection. eg:
string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
accessConn = new OleDbConnection(jetConn);
hope it helps
|
|
|
|
|
|
Where can see the information?
I'm amumu, and you?
|
|
|
|
|
Either read the data in a OleDbDataReader or a OleDbDataAdapter. EG
string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
accessConn = new OleDbConnection(jetConn);
string query = "SELECT * FROM TABLE WHERE etc etc";
OleDbCommand myCommand = new OleDbCommand(query, accessConn);
OleDbDataReader myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
string datain = myReader.GetString(0);
}
DataTable dt = new DataTable();
OleDbDataAdapter sda = new OleDbDataAdapter(query, accessConn);
sda.Fill(dt);
Hope this helps
|
|
|
|
|
Thank you
This method can work properly.
I'm amumu, and you?
|
|
|
|
|
Hello once again my fellow CPains!
I have one quick question I would like to ask, what would be the best way to determine the amount of items in an array which would allow me to store that amount into an integer?
|
|
|
|
|
brian1415 wrote:
my fellow CPains!
I don't think you will get an answer if you are that rude to the people.
brian1415 wrote:
what would be the best way to determine the amount of items in an array which would allow me to store that amount into an integer?
Now that is really confusing question
I have never wasted time worrying about such insignificant things. Keep your eye upon the donut and NOT upon the hole. - Bill Sergio about posting in the right forum. The Lounge - June 23, 2002
|
|
|
|
|
I am sorry that was a very foolish question and I promptly figured out how I would do it. Sorry for wasting you time.
|
|
|
|
|
So what was the question and what is the answer?
I have never wasted time worrying about such insignificant things. Keep your eye upon the donut and NOT upon the hole. - Bill Sergio about posting in the right forum. The Lounge - June 23, 2002
|
|
|
|