c# - how can i use 1 contextmenustrip on many buttons -


my program has many buttons. use "1" contextmenustrip when right click on button options "change color red". problem dont know how code button.

    private void changecolortoolstripmenuitem_click(object sender, eventargs e) {     btn1.backcolor = color .red; } 

now can change color 1 button if need buttons takes long time , need use more 1 contextmenustrip. need change color button right click.

i sorry bad english if not clear try explain again. thanks

you can use sourcecontrol() property of main contextmenustrip determine button source of event:

    private void changecolortoolstripmenuitem_click(object sender, eventargs e)     {         control ctl = contextmenustrip1.sourcecontrol;         ctl.backcolor = color.red;     } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -