Hi All
I am using Visual studio 2005(c#) for creating my windows application. In my parent form (i.e. Mdi container) I am using menu strip control. when i am clicking menu strip, child window is loading on parent window and I am disabling menu strip,up to this its working fine. The problem is when I am closing the child window by using the click event of the button which is in child ,I am struggling to enable the menu strip in the parent window . Any one helps me solve this.
ganesh kuppuswanyPosted Nov 11, 2007, 11:03 PM
Hi friend
1.While executing my project ,the highlighted blue line in the below code gives error as 'Top-level control cannot be added to a control.'.
ChildFrm objChild=new ChildFrm();
objChild.parent = this;
mnustrip.enable = false;
objChild.ShowDialogue();
2. In the child form in the close event.I am unable to access the public function EnableMenustrip() which is in parent form by using the below code .
this.Parent.EnableMenustrip();
Arun KumarPosted Nov 9, 2007, 9:49 PM
While invoking the child from from parent form U can pass a referece of parent ot the child or set the childform parent property as parent form reference as follows:
Mainform:
----------------------------------------
ChildFrm objChild=new ChildFrm();
objChild.parent = this;
mnustrip.enable = false;
objChild.ShowDialogue();
---------------------------------------
The main form should have a public function like this
public void EnableMenustrip()
{
mnustrip.Enable = true;
}
----------------------------------------
Next in the Child form,
1. Select the Form Closing Even and write the code as follows:
this.Parent.EnableMenustrip();
This function will be invoked when the child closing event fired..
I think this is feature you were expecting for
- AMG