Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Iceplug
Posted

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

Software bugs are impossible to detect by anybody except the end user.
Posted

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..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...