Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Enable/Diseable Main menu

Enable/Diseable Main menu

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    charchabil03
    wrote on last edited by
    #1

    Having initially a diseabled main menu, how can i enable this menu when the user loggon? and diseable it when the user logout? other then using me.item1.enable=true me.item2.enable=true is there a way like : for each item in menu item.enable=true?? regards?

    Regards Ramy

    T 1 Reply Last reply
    0
    • C charchabil03

      Having initially a diseabled main menu, how can i enable this menu when the user loggon? and diseable it when the user logout? other then using me.item1.enable=true me.item2.enable=true is there a way like : for each item in menu item.enable=true?? regards?

      Regards Ramy

      T Offline
      T Offline
      TwoFaced
      wrote on last edited by
      #2

      I assume you've added a MenuStrip to your form? You can disable the whole menu by setting it's enabled property to false and enable it by setting that property to true. You don't need to do on an item by item basis, unless I'm not understanding you correctly.

      C 1 Reply Last reply
      0
      • T TwoFaced

        I assume you've added a MenuStrip to your form? You can disable the whole menu by setting it's enabled property to false and enable it by setting that property to true. You don't need to do on an item by item basis, unless I'm not understanding you correctly.

        C Offline
        C Offline
        charchabil03
        wrote on last edited by
        #3

        yes i have used a menustrip what i want when theu user Log enable the menu when he logout ,disbale the menu

        Regards Ramy

        T 1 Reply Last reply
        0
        • C charchabil03

          yes i have used a menustrip what i want when theu user Log enable the menu when he logout ,disbale the menu

          Regards Ramy

          T Offline
          T Offline
          TwoFaced
          wrote on last edited by
          #4

          Then my previous advice should work. Just use MenuStrip1.Enabled = False and MenuStrip1.Enabled = True.

          C 1 Reply Last reply
          0
          • T TwoFaced

            Then my previous advice should work. Just use MenuStrip1.Enabled = False and MenuStrip1.Enabled = True.

            C Offline
            C Offline
            charchabil03
            wrote on last edited by
            #5

            but what u suggest MenuStrip1.Enabled = False enable and diseable all the menu ,means enables the login menu also// so how the user will logon

            Regards Ramy

            T 1 Reply Last reply
            0
            • C charchabil03

              but what u suggest MenuStrip1.Enabled = False enable and diseable all the menu ,means enables the login menu also// so how the user will logon

              Regards Ramy

              T Offline
              T Offline
              TwoFaced
              wrote on last edited by
              #6

              You stated you wanted to disable/enable the main menu. This to me meant the whole menu. To individually set items you can create a loop that iterates through each item and disable/enables it.

                  'Option #1
                  With MenuStrip1
                      'Disable each menu item
                      For i As Integer = 0 To .Items.Count - 1
                          .Items(i).Enabled = False
                      Next
                      'Enable the one(s) we want by index
                      .Items(0).Enabled = True
                  End With
              
                  'Option #2
              
                  'Disable each menu item
                  For Each item As ToolStripItem In MenuStrip1.Items
                      item.Enabled = False
                  Next
                  'Enable by using it's name
                  MenuStrip1.Items("FileToolStripMenuItem").Enabled = True
              

              Enabling the items would just be a simple change

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups