Merged menus (enable/disable them)

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

I have a form with a main menu on it (mdi parent form) and i have a child
form with a menu and I am mergeing the menus together for the menu called
reports.. now when i do this they merge just fine.. but i need to disable
the menu when the user logs out of the system or clear it so they cant run
reports still after logout. but when i try to set the mdi parent's menu's
mnuReports item's enabled property to false it throws an item isnt set to an
instance of an object exception back. why would it cause this? and how would
i go about placeing a security constraint like this on a merged menu? thanks
 
Hi. Brian

it could be because after merge you have 2 different menu items - one in mdi
menu and another in mnuReports. If you use menu item from mnuReports - it's
not present in mdi menu.

HTH
Alex
 
any ideas on how to do something like this though? any code can be changed
that needs to be.
 
Hi, Brian

you might need to loop through mdi menu and find out which menu items to
disable.
Another way - disable your mnuReport items and recreate mdi menu anew.

HTH
Alex
 
Hi Brian,

As Alex said, we can loop through the menuitems to disable certain item.
e.g.

Dim mm As MainMenu = Me.Menu
For Each o As MenuItem In mm.MenuItems
'disable the first menuitem in Child form
o.MenuItems(0).Enabled = False
Debug.WriteLine(o.Text)
Next
mm = Me.MdiParent.Menu
For Each o As MenuItem In mm.MenuItems
'disable the first menutiem in MDIParent form
o.MenuItems(0).Enabled = False
Debug.WriteLine(o.Text)
Next

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top