ChildForm...

I nedd your help, guys.

I've a rather simple win app: main form with simple menu & child form. I want to call child form from menu, do some operations on child form & then I want to change text on main form.

So, my 1st attempt was rather simple: on child form I've tried (child form is called from menu item):

this.ParentForm.Text = "Registered";

but I've received an error that parent cannot be determined.

So I've read help where is told that main form has to have property IsMdiContainer set to true. So I've made it and changed menu click handler to:

private void menuItem10_Click(object sender, System.EventArgs e) {
Register register = new Register(SerialNumber, RegisteredFrom);
register.MinimizeBox = false;
register.MaximizeBox = false;
register.StartPosition = FormStartPosition.CenterScreen;
register.MdiParent = this;
register.Show();
}

Now I'm sure that ParentForm property on child form can be determined, but when I click menu to call child form nothing's happening. Why

Next question probably be how to call a method defined in parent form, but it's after solution of this problem  :)  


Answer this question

ChildForm...

  • Dan Vallejo - RampGroup

    i would normally settle for event base architecture, it's widely used including in the windows form it self, the same thing when you have a button on a form, when a button is click , you hook it in the form... so now think the button as your child form and the form as your MDI container( well the form has a reference to the button and in your case your MDI parent has a reference to the child form) , i' ve posted some sample codes in this forums for you to look at
  • Asim Zeeshan

    Sorry this example is in VB but...

    Dim myParent As MDIParentForm = CType(Me.MdiParent, MDIParentForm)

    myParent.Text = "Registered"

  • ChildForm...