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. How to know which control called the context menu?

How to know which control called the context menu?

Scheduled Pinned Locked Moved C#
questiontutorial
5 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    bouli
    wrote on last edited by
    #1

    Hello gurus, I have a context menu shared by 3 controls. Those controls are simply panels that have the same context menu. I would like to know how I it is possible to know which panel is the owner of the context menu and called the click event. I thought the sender parameter of the click event was the owner of the context menu but it is not. So, how can I know the owner of the context menu??? I hope my question was clear. Thanks in advance for your answers. Best regards. Fred.

    There is no spoon.

    C 1 Reply Last reply
    0
    • B bouli

      Hello gurus, I have a context menu shared by 3 controls. Those controls are simply panels that have the same context menu. I would like to know how I it is possible to know which panel is the owner of the context menu and called the click event. I thought the sender parameter of the click event was the owner of the context menu but it is not. So, how can I know the owner of the context menu??? I hope my question was clear. Thanks in advance for your answers. Best regards. Fred.

      There is no spoon.

      C Offline
      C Offline
      Christian Flutcher
      wrote on last edited by
      #2

      sender is the one. Have you tried casting sender to a panel instance?

      Panel panel = sender as Panel;
      if(panel != null)
      // do your stuff

      B 1 Reply Last reply
      0
      • C Christian Flutcher

        sender is the one. Have you tried casting sender to a panel instance?

        Panel panel = sender as Panel;
        if(panel != null)
        // do your stuff

        B Offline
        B Offline
        bouli
        wrote on last edited by
        #3

        I'm getting a null value.

        There is no spoon.

        C 1 Reply Last reply
        0
        • B bouli

          I'm getting a null value.

          There is no spoon.

          C Offline
          C Offline
          Christian Flutcher
          wrote on last edited by
          #4

          Is your sender NULL or the casting failed? Step into the code and check what value sender has.

          B 1 Reply Last reply
          0
          • C Christian Flutcher

            Is your sender NULL or the casting failed? Step into the code and check what value sender has.

            B Offline
            B Offline
            bouli
            wrote on last edited by
            #5

            The casting gave me a null vaue. That's really odd.

            There is no spoon.

            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