Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'd like to disable all MenuItems (menu File, Edit, View, Help, etc..)

 

I have a function which disables all controls in a container:

'Function that Disables or Enables all controls in a container control
Public Sub EnableDisableObject(ByVal Enable As Boolean, ByVal Container As Control)
 Dim Control As Control
 For Each Control In Container.Controls
   Control.Enabled = Enable
 Next
End Sub

 

but the problem is that MenuItem is not a controll. How can I do it?

 

tx a lot

 

matej

Posted

Loop through the MainMenu's menuitem collection.

 

Dim obj As MenuItem

       For Each obj In Me.MainMenu1.MenuItems
           obj.Enabled = False
       Next

"Nobody knows what I do until I stop doing it."
Posted

Instead of doing all of the menu items. All you have to do is set enable to false on the top level items.

 

me.mnuFile.enabled = false

...etc

 

Hope this helps

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

-- Rick Cook, The Wizardry Compiled

  • Leaders
Posted
Instead of doing all of the menu items. All you have to do is set enable to false on the top level items.

 

me.mnuFile.enabled = false

...etc

 

Hope this helps

I believe that that is exactly what the code provided does. Enumerates through all the top level menus in MainMenu1 and sets their enabled property to false.

[sIGPIC]e[/sIGPIC]
Posted

My Bad.

 

I thought (my big mistake) that it loop through all the menu items not just the top level. Well you learn something new every day.

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

-- Rick Cook, The Wizardry Compiled

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