When you create your other forms from the main form, or at some other place,
pass a reference to your main form in the constructor. Like this:
Add a mebmer variable in your child forms:
private MainForm myMainForm;
In the child forms constructor add a parameter
public ChildForm(MainF orm myMainForm)
{
this.myMainForm = myMainForm;
}
When you want to show the child form, from the mainform:
ChildForm childForm = new ChildForm(this) ;
childForm.Show( );
Now it's possible to access the main form from a method in you child form:
private void SomeMethod()
{
string text = myMainForm.Text ;
}
/Henke
"Giulio Mastrosanti" <gi****@cantobe ron.it> skrev i meddelandet
news:OQ******** ********@TK2MSF TNGP11.phx.gbl. ..
Henke, thank you for your answer,
But what do you mean exactly?
Thank you
Giulio
Henke wrote: Why not passing a reference in the constructor of the other form?
/Henke
"Giulio Mastrosanti" <gi****@cantobe ron.it> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Which is the instance name of the starting form of an application?
I want to access his controls and variables from another form but can't
find the way...
Which is the property I can use and must i cast it in some way?
Thanx,
Giulio