> Hello,
> Can anyone point me to the code for a simple example of 2 classes and /
[quoted text clipped - 3 lines]
> I know this is simple stuff, but there doesnt seem to be much out
> there.
It is simple stuff, and isn't unique to Form-derived classes. It's basic
OOP.
That said, here's a simple example (class members unrelated to the
specific question omitted for brevity):
class Form1 : Form
{
void ShowForm2()
{
using (Form2 form2 = new Form2())
{
form2.ShowDialog();
MessageBox.Show(form2.Data);
}
}
}
class Form2 : Form
{
public String Data
{
get { return "Form2 Data"; }
}
}
If the form's not modal and you need Form1 to keep the reference, then it
will need to store that reference in a field somewhere. If Form2 needs a
reference to Form1, you can provide that when you create the Form2
instance. For example, pass the reference of Form1 to the constructor of
Form2, or set a property on Form2 after it's been instantiated.
Pete