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. Menu Item Name?

Menu Item Name?

Scheduled Pinned Locked Moved Visual Basic
question
7 Posts 3 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.
  • R Offline
    R Offline
    Rana Muhammad Javed Khan
    wrote on last edited by
    #1

    how can i access the Menu Item Name Property through code:confused: :confused:

    J 1 Reply Last reply
    0
    • R Rana Muhammad Javed Khan

      how can i access the Menu Item Name Property through code:confused: :confused:

      J Offline
      J Offline
      JUNEYT
      wrote on last edited by
      #2

      If you have added a contextmenu on your form, you should be able to access to each menu item's property eg: menuitem1.text = "Hello!"

      R 1 Reply Last reply
      0
      • J JUNEYT

        If you have added a contextmenu on your form, you should be able to access to each menu item's property eg: menuitem1.text = "Hello!"

        R Offline
        R Offline
        Rana Muhammad Javed Khan
        wrote on last edited by
        #3

        I want to access Name Property my code is as: Dim mnuItem As MenuItem For Each mnuItem In OfrmMain.mnu_Main.MenuItems If **mnuItem.Name** ="NameofMenu" Then 'Do some thing End If Next Regards

        J D 2 Replies Last reply
        0
        • R Rana Muhammad Javed Khan

          I want to access Name Property my code is as: Dim mnuItem As MenuItem For Each mnuItem In OfrmMain.mnu_Main.MenuItems If **mnuItem.Name** ="NameofMenu" Then 'Do some thing End If Next Regards

          J Offline
          J Offline
          JUNEYT
          wrote on last edited by
          #4

          Hello Javed! you have confused me! :)) Your code is okay there is no error. If your are still not able to get the menu name that means you have to check your contextmenu name to make sure you are tryign to use the right menu collection. mnuItem.Name must return a value as you have defined in your code. If you have more than one menu collection make sure you have pointed to right collection. Otherwise, re-check the menu name which you have tried in seeking its equality to mnuItem.Name.. Take it easy!

          R 1 Reply Last reply
          0
          • J JUNEYT

            Hello Javed! you have confused me! :)) Your code is okay there is no error. If your are still not able to get the menu name that means you have to check your contextmenu name to make sure you are tryign to use the right menu collection. mnuItem.Name must return a value as you have defined in your code. If you have more than one menu collection make sure you have pointed to right collection. Otherwise, re-check the menu name which you have tried in seeking its equality to mnuItem.Name.. Take it easy!

            R Offline
            R Offline
            Rana Muhammad Javed Khan
            wrote on last edited by
            #5

            My Friend Problem is this that Menu Object dos't expose the "Name" Property.... Regards :^)

            1 Reply Last reply
            0
            • R Rana Muhammad Javed Khan

              I want to access Name Property my code is as: Dim mnuItem As MenuItem For Each mnuItem In OfrmMain.mnu_Main.MenuItems If **mnuItem.Name** ="NameofMenu" Then 'Do some thing End If Next Regards

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Of course. There is no Name property for a MenuItem. If you can't set one, why would you be looking to read it? You can, however read its Text property. Doing what you're looking at in your sample code is not good practice. Each menuitem should handle its own Click event. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              R 1 Reply Last reply
              0
              • D Dave Kreskowiak

                Of course. There is no Name property for a MenuItem. If you can't set one, why would you be looking to read it? You can, however read its Text property. Doing what you're looking at in your sample code is not good practice. Each menuitem should handle its own Click event. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                R Offline
                R Offline
                Rana Muhammad Javed Khan
                wrote on last edited by
                #7

                Thanks for ur response. Actually i want to implement user security. My working is as: I will make Roles and Role will be given rights to access "MENU" and user will be assign the role. Now i want to write a code which show all the menus in a grid i want to save the NAME of the MENU in a hidden column which will be saved in the database. Now i have decided to save the Menu Text in database which i know can cause problem becuase if menu text is changed it will have to be changed in database too. As menu item name is not changed so if it is saved it will cuase no problem... hope u will have got my point if u have any better suggestion will be benificial for me. Regards Javed

                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