c# - How to add to ContextMenuStrip and ToolStrip same ToolStripButtons? -


i have tool bar in app , context menu same options, want add toolstripbuttons both contextmenustrip , toolstrip, unfortunately can't this. when add manually items both shows on one.

for have buttons in tool bar:

i want this. want options one, because enable , disable buttons , there 1 option why 2 buttons?

this common problem , i've found easiest solution place 'shared' code inside menufeature class inherits toolstripmenuitem.

you still have create 2 instances of class, each instance lightweight , has code differences between 2 usages (i.e. contextmenu item might use toolstripitemdisplaystyle.imageandtext, while toolstrip item might use toolstripitemdisplaystyle.image).

this allows common code exist once inside custom menufeature class, still allows changes local each usage of menu item.

if wanted automatically synchronize properties enabled/visible/etc, maintain static collection of instances inside constructor, , update items using events enabledchanged/etc. recommend against this, however, i've found different instances of same menu 'feature' need own state - getting out of scope on question, interested in how i've managed items can comment on answer or pm me.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -