Question


Is there possible to disable child's form buttons from parent form? For example, I have 2 radio-buttons in parent form, one is True second False, when I choose one of them fires radiobutton.CheckedChanged event and there I have code what goes like this, but it's not working:

ChildForm.Button1.Enabled = False

where seems to be the problem? Can anyone help with this?

Was it helpful?

Solution

You would need to create an instance of the childform.

So...

ChildForm cf = new ChildForm();
cf.Button1.Enabled = false;

You have to keep in mind though, it could be a different instance than the child form that is currently being shown.

To be sure, depending on your code (which I can't see) and how your program is laid out I would probably do something like this...

ChildForm cf = new ChildForm();
cf.show();
cf.Button1.Enabled = false;

so here I know that the ChildForm that is showing is the one that has the button disabled.

OTHER TIPS

In VB6 the following project works:

1 MDI form:

Option Explicit

Private Sub MDIForm_Click()
  Form1.Option1.Enabled = False
End Sub

Private Sub MDIForm_Load()
  Form1.Show
End Sub

Form1 is a MDI child form with 2 radio buttons on it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top