how to get clicked button of context menu strip

Basically the title. The screenshot is as far as i got
18 Replies
Boggo
Boggo2y ago
Do you mean determine which button was clicked?
Diesel Geezer
Diesel GeezerOP2y ago
yes
Boggo
Boggo2y ago
Likely not the only way, but one way i use is to simply have an event for each item in the CMS
Boggo
Boggo2y ago
Boggo
Boggo2y ago
for example, this is my strip double click delete, youll get
Boggo
Boggo2y ago
Boggo
Boggo2y ago
Is that what your after? I am doing a similar thing in my project as we speak
Diesel Geezer
Diesel GeezerOP2y ago
do this for every button?
Diesel Geezer
Diesel GeezerOP2y ago
well i just got a better idea. Here is what i did I made this click function
Diesel Geezer
Diesel GeezerOP2y ago
Diesel Geezer
Diesel GeezerOP2y ago
and i put it in the click event of every button
Boggo
Boggo2y ago
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
Diesel Geezer
Diesel GeezerOP2y ago
Just finished it and it works i will add a lot more buttons thats why i need a single function to do everything
Diesel Geezer
Diesel GeezerOP2y ago
finished
Boggo
Boggo2y ago
yes this looks better than mine xD, probably will use this instead
Diesel Geezer
Diesel GeezerOP2y ago
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
Diesel Geezer
Diesel GeezerOP2y ago
Diesel Geezer
Diesel GeezerOP2y ago
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
Want results from more Discord servers?
Add your server