mcerk Posted February 22, 2005 Posted February 22, 2005 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 Quote
Rick_Fla Posted February 22, 2005 Posted February 22, 2005 Loop through the MainMenu's menuitem collection. Dim obj As MenuItem For Each obj In Me.MainMenu1.MenuItems obj.Enabled = False Next Quote "Nobody knows what I do until I stop doing it."
SonicBoomAu Posted February 24, 2005 Posted February 24, 2005 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 Quote 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 snarfblam Posted February 24, 2005 Leaders Posted February 24, 2005 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. Quote [sIGPIC]e[/sIGPIC]
Rick_Fla Posted February 24, 2005 Posted February 24, 2005 Correct, each menuItem has it's own menuitem collection. The code I provided will do just the top level. Quote "Nobody knows what I do until I stop doing it."
SonicBoomAu Posted February 24, 2005 Posted February 24, 2005 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. Quote 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
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.