MDI parent and child properties
From the MDI parent form, I can change the properties of controls in the child form. Similarly, is there any way I can manipulate the static variables in the child form?
foreach (Form childForm in MdiChildren)
{
DataGridView dgview = (DataGridView)childForm.Controls["dataGridView1"];
dgview.Columns[1].Visible = true;
dgview.Columns[2].Visible = false;
}
[473 byte] By [
rkbnair] at [2007-11-11 7:31:55]

# 1 Re: MDI parent and child properties
If you declare the variables as public, you can access them from outside the form class.
# 2 Re: MDI parent and child properties
We can access a control by using ChildForm.controls["mycontrol"]. However, what would be the syntax to get the value of a public variable defined in a child form?
# 4 Re: MDI parent and child properties
Here, the real problem is that I do not know the name of my ChildForm.
so, when I say value = ChildForm.PublicVariableName, the compiler will say
'PublicVariableName is not defined.'
# 5 Re: MDI parent and child properties
In order to access a public field (variable) or property of a class, you must either have an instance of that class, or know the name of the class (if the field or property is static). Without either of those, I know of no way to access the value.