how to get clicked button of context menu strip
Basically the title. The screenshot is as far as i got
18 Replies
Do you mean determine which button was clicked?
yes
Likely not the only way, but one way i use is to simply have an event for each item in the CMS
for example, this is my strip
double click delete, youll get
Is that what your after? I am doing a similar thing in my project as we speak
do this for every button?
well i just got a better idea. Here is what i did
I made this click function
and i put it in the click event of every button
maybe this works too, i am not normally helping people, normally asking for help xD just saw the same problem im after.
i have only two buttons, so two events works fine for me
but its going to be neater to have only one event, like your code here
Just finished it and it works
i will add a lot more buttons thats why i need a single function to do everything
finished
yes this looks better than mine xD, probably will use this instead
depends on what you want to achieve. My context menu strip has colored buttons that when clicked i want them to change the border color of another button based on their own color.
If you want each button to do very different things, then my solution will not be efficient. For example if one button opens google chrome, and the other deletes a file, then my solution is useless. You will have to use an if statement and check which button was clicked to execute the right action
here is an example
as you can see, my solution works, but its just not efficient. You could do the same by having seperate click events for each button and not using any if statements