muliple forms and objects
Hello,
I have a solution with multiple forms under the same namespace. I want to be able to read the contents of a listbox on one form into a listbox on a second form. I can't seem to get them to work correctly.
If I set one of the listbox to be public static, it works, but I then can't open the form in the form designer - it tells me that the listbox name is undefined.
Can anybody help me with this problem?
Thanks
Mike GoldPosted May 24, 2007, 6:51 PM
You should pass one form to another in the constructor and assign a reference to it. Then call methods on the other form through it's reference.
e.g.
Form1 _form1 = null;
Form2 (Form1 form)
{
_form1 = form;
}
void DoMyListBoxChangeToForm1()
{
_form1.DoListBoxChange();
}