I'm using VS 2008, and I would like to add a contextMenu (definitely not ContextMenuStrip
!!) to my application. There is no contextMenu (!!) in the toolbox. So how can I add it programmatically to my code?
Thanks In Advance,
I assume you use Winforms, you can initialize ContextMenu
class in your code. It has a 2 constructor which you can pass MenuItem
as a parameter.
ContextMenu cm = new ContextMenu();
or
ContextMenu cm1 = new ContextMenu(new MenuItem[]);
ContextMenu context = new ContextMenu();
context.Items.Add(new MenuItem().Header = "Add To Favorites");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With