I have a main form with a panel in which loads other forms. How can I let
the forms loaded into panels modify properties of the main form?
If I use:
FrmMain.Text = "Whatever"
from my panel form, I get the error: "Reference to a non-shared member
requires an object reference.". Do I need to create a static method in my
main form code or something?
Sorry if this is a silly question!
TIA,
Chris
Sijin Joseph - 13 Oct 2004 05:33 GMT
One way would be pass an instance of the MainForm in either the
constructor or in a seperate method to the child forms.
Something like this
ChildForm cf = new ChildForm(this);
this.Panel1.Controls.Add(cf);
and inside ChildForm
public ChildForm(Form parentForm)
{
parentForm.Text = "Whatever";
}
A cleaner approach would be to use Interfaces, but the above will work
too, let me know if you have any problems getting this implemented.
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> I have a main form with a panel in which loads other forms. How can I let
> the forms loaded into panels modify properties of the main form?
[quoted text clipped - 12 lines]
>
> Chris