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. C#
  4. Context Menu - Display Member, Value member

Context Menu - Display Member, Value member

Scheduled Pinned Locked Moved C#
sales
5 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.
  • R Offline
    R Offline
    Ruchi Gupta
    wrote on last edited by
    #1

    Hi All, I have a ContextMenu. At the leaf node user want to see both the Code and description as follows. 1 - Employee 2 - Customer 3 - Administrator Is there any property similar to ValueMember (as we have in ComboBox) in MenuItem. I want to be able to get value of code i.e. 1 or 2 or 3 when a leaf node is selected. Thanks Ruchi

    H 1 Reply Last reply
    0
    • R Ruchi Gupta

      Hi All, I have a ContextMenu. At the leaf node user want to see both the Code and description as follows. 1 - Employee 2 - Customer 3 - Administrator Is there any property similar to ValueMember (as we have in ComboBox) in MenuItem. I want to be able to get value of code i.e. 1 or 2 or 3 when a leaf node is selected. Thanks Ruchi

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You mean like MenuItem.Index?

      Microsoft MVP, Visual C# My Articles

      R 1 Reply Last reply
      0
      • H Heath Stewart

        You mean like MenuItem.Index?

        Microsoft MVP, Visual C# My Articles

        R Offline
        R Offline
        Ruchi Gupta
        wrote on last edited by
        #3

        No, not index. code and Description can be 167 - Employee 256 - Administrator 234 - Customer So what I am displaying on the leaf node in above information. But when any of above node is selected, I want to get 167 or 256 or 234 as the value. LIke in combobox, we set Display member and valuemember. Rigth now I am tokenizing the leaf node upon selection as - dealNo = dealNo.Substring(0, dealNo.IndexOf("-", 0)); to get the reqired piece of information.

        H 1 Reply Last reply
        0
        • R Ruchi Gupta

          No, not index. code and Description can be 167 - Employee 256 - Administrator 234 - Customer So what I am displaying on the leaf node in above information. But when any of above node is selected, I want to get 167 or 256 or 234 as the value. LIke in combobox, we set Display member and valuemember. Rigth now I am tokenizing the leaf node upon selection as - dealNo = dealNo.Substring(0, dealNo.IndexOf("-", 0)); to get the reqired piece of information.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          The MenuItem isn't a data-binding control like the ComboBox. What you see is what you get - there is nothing "behind the scenes" that track information like this. That doesn't mean you can't add it, though. Extend the MenuItem class with your own and add a property to hold this information. In the MenuItem.Click handler elsewhere in your code, you cast the sender (the first parameter) to your MenuItem derivative class and get the value of that property.

          Microsoft MVP, Visual C# My Articles

          R 1 Reply Last reply
          0
          • H Heath Stewart

            The MenuItem isn't a data-binding control like the ComboBox. What you see is what you get - there is nothing "behind the scenes" that track information like this. That doesn't mean you can't add it, though. Extend the MenuItem class with your own and add a property to hold this information. In the MenuItem.Click handler elsewhere in your code, you cast the sender (the first parameter) to your MenuItem derivative class and get the value of that property.

            Microsoft MVP, Visual C# My Articles

            R Offline
            R Offline
            Ruchi Gupta
            wrote on last edited by
            #5

            Thanks for prompt response. You are a genius. Ruchi:)

            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