Getting the value of an MDIParent control

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I'm creating a simple mdi windows forms app. I have some radio buttons on
the MDI Parent that I want to access from the child forms. Is there any
other way to access the control than by using the index of the control in
the Parent's controls collection?? There has to be a way to get it by name.
If not, ......... that's Jacked!!
ie.
this.MdiParent.Controls[1]



Please help.

Mark
 
Mark said:
I'm creating a simple mdi windows forms app. I have
some radio buttons on the MDI Parent that I want
to access from the child forms. Is there any
other way to access the control than by using the
index of the control in the Parent's controls
collection?? There has to be a way to get it
by name. If not, ......... that's Jacked!!
ie.
this.MdiParent.Controls[1]

\\\
((RadioButton)this.MdiParent.Controls[1]).CheckAlign =
ContentAlignment.TopCenter
///
 
If your main form is called Form1, then do something like
Form1 parentForm = this.MdiParent;
After that you can access the radio buttons directly from "parentForm".
 
The simple answer is, one form shouldn't be accessing the controls of
another form directly. It's bad design, because it makes it much harder
to make changes to either form in the future. ("But I wanted a combo
box, not radio buttons!" is something you'll hear all too often.)

You should add a property to the MDI parent, and have that property
expose the information the child form needs.
 
Back
Top