Passing data between Windows Forms(newbie to desktop applications)

W

weird0

Hey!! someway( what i call i a MindFreak Technique!!) I managed to
pass data from one form to another. But still i can't really
understand the reference thing to pass data between forms.

I have three forms:

class Form1
{


}

class TreeViewForm
{

event()
{
// create object and nodeproperties
}

}

class NodeProperties
{
Node currNode; // I have a node object inside of this class.... the
top two classes also contain the same object...

}


But hey!! How do i update the same objects inside Form1 and
TreeViewForm?????????? which means passing data backward to Forms!!
Even if i keep a reference of the first two classes inside third
class.. ref object and pressing dot does not allow me to access the
class data members. Even if it does, will it allow me to access the
same data.????

I am a newbie to C# desktop programming.

Need help
Regards
 
B

bob clegg

Hey!! someway( what i call i a MindFreak Technique!!) I managed to
pass data from one form to another. But still i can't really
understand the reference thing to pass data between forms.

I have three forms:

class Form1
{


}

class TreeViewForm
{

event()
{
// create object and nodeproperties
}

}

class NodeProperties
{
Node currNode; // I have a node object inside of this class.... the
top two classes also contain the same object...

}


But hey!! How do i update the same objects inside Form1 and
TreeViewForm?????????? which means passing data backward to Forms!!
Even if i keep a reference of the first two classes inside third
class.. ref object and pressing dot does not allow me to access the
class data members. Even if it does, will it allow me to access the
same data.????

I am a newbie to C# desktop programming.

Need help
Regards
Hi,
Suggest you look at creating custom events that carry the data as
payload.
So if form1 is allowed to pass data to form2 and vice versa then form1
has a custom event that form2 handles and vice versa.

If the data is in a class / struct that is separate from either
form, both forms can create instances of it as required.

Also don't overlook the treenode 'Tag' property. You can hang your
data here so you are not having the data as part of the node.
(I used to derive classes from TreeNode before I finally realised
this.)
hth
bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top