eramgarden Posted January 17, 2005 Posted January 17, 2005 (edited) Originally from http://www.xtremedotnettalk.net/showthread.php?t=77613 I did this: In MainForm (parent form), when the form is first loaded : mnuView.Enabled = false; Also created a routine to enable the menus: public void enableMenus() { mnuView.Enabled= true; } In child form frmMDIMain mainframe = new frmMDIMain(); mainframe.enableMenus(); I set debug. It DOES go thru that routine but still wont enable!! Any ideas?? Edited January 18, 2005 by Iceplug Quote
Administrators PlausiblyDamp Posted January 17, 2005 Administrators Posted January 17, 2005 You need to refer to the current instance of the parent form - not create a new instance. Read over some of the above posts as they tell you what you need to do. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted January 17, 2005 Posted January 17, 2005 I'm assuming that you want to enable/desable the menus from an MDI Child form... In this case you can simply use the MDIParent property to get a pointer to the form. Tho, to use embeded method public void enableMenus() you need to cast the type... something like: 'Assume that: ' - this code is runned on a child form called frmChild ' - the parent MDI Form is called frmMain 'This can be placed wherever you need to enable the menus. dim _frmMain as frmMain _frmMain = me.MDIParent _frmMain.enableMenus or simply: DirectCast(me.MDIParent,frmMain).enableMenus Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
eramgarden Posted January 17, 2005 Author Posted January 17, 2005 Yeah, but still light bulb is dim.. If I do this in ChildForm, it works: this.MdiParent.Menu.MenuItems[4].Enabled= true; But I want to use the method mentioned above.. I am following the example... In Childform ..I did this: frmMDIMain frmMain = this.MdiParent; But get an error. I do have all that frmchild.show like this: private void menuOpenDB_Click(object sender, System.EventArgs e) { frmDatabaseOpen objDatabaseOpen = new frmDatabaseOpen(); objDatabaseOpen.MdiParent= this; objDatabaseOpen.Show(); } but still no luck..found other examples but in VB and when I convert them, they dont work.. Quote
AlexCode Posted January 17, 2005 Posted January 17, 2005 But get an error. What error?? Quote Software bugs are impossible to detect by anybody except the end user.
eramgarden Posted January 17, 2005 Author Posted January 17, 2005 Oh, I GOT IT... ((frmMDIMain)this.MdiParent).enableMenus(); In child menu. THANK YOU SO MUCH for your help! Quote
AlexCode Posted January 17, 2005 Posted January 17, 2005 :D worked? Nice... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.