How to know which control called the context menu?
-
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.
-
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.
sender is the one. Have you tried casting sender to a panel instance?
Panel panel = sender as Panel;
if(panel != null)
// do your stuff -
sender is the one. Have you tried casting sender to a panel instance?
Panel panel = sender as Panel;
if(panel != null)
// do your stuff -
Is your
sender
NULL or the casting failed? Step into the code and check what valuesender
has. -
Is your
sender
NULL or the casting failed? Step into the code and check what valuesender
has.