Subject: How to make enable true for menuItem in C#
Posted By: akumarp2p Post Date: 12/11/2006 7:03:01 AM
Hi
I have to create a menu & it's menuItem in MainForm of my application but when i Click on that menu item.i make it enable property false.
Now I want to Make enable property true for MainForm when Closes my SubForm.
Ok.
Send me idea how to do this.
Very Urgent

Thanks and Regards
Kumar Ashish
9350789189
Reply By: gaurav_jain2403 Reply Date: 12/15/2006 4:32:10 AM
You can do as follow. In the Main Form you write these lines in InitializeComponent() method:
MainMenu mainMenu1 = new MainMenu();
MenuItem mItem1 = new MenuItem("&Command");
mItem1.MenuItems.Add(new MenuItem("click here",new EventHandler(Commands)));
mainMenu1.MenuItems.Add(mItem1);
this.Menu = mainMenu1;
this.IsMdiContainer = true;

Then make another method as follow:
private void Commands(object sender,System.EventArgs e)
        {
Form2 frm2 = new Form2();
frm2.Show();
frm2.MdiParent = this;
this.Menu.MenuItems[0].Enabled = false;
        }
Till now it is fine. In the Sub form write this method:
private void Form2_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
this.MdiParent.Menu.MenuItems[0].Enabled = true;
        }
Hope this will solve your problem... All the best

Gaurav

Go to topic 53668

Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86
Return to index page 85
Return to index page 84
Return to index page 83