Is there a way to put an icon next to the text in a MenuItem?
I use the following code to display a popup menu when the user right clicks in a user control:
ContextMenu menu = new ContextMenu();
MenuItem item = new MenuItem("test", OnClick);
menu.MenuItems.Add(item);
menu.Show(this, this.PointToClient(MousePosition));
I would like to put a icon to the left of the "test" string in the popup menu so that the user more easily recognizes it. Is there a way to do this other than by setting the OwnerDraw property to true (thus requiring me to completely draw the menu item myself, like it is done in this example: http://www.codeproject.com/KB/menus/cs_menus.aspx)?
Any help is appreciated.
Find the right menu and add an icon To add WordPress menu icons, select any of the menu items you already have created. Locate the Icon: Select link. Click on that to navigate to the section to add an icon to that particular menu item.
We can do this by adding the menu-item-float-right class to the menu item. First, make sure the CSS Classes field is enabled by clicking on Screen Options at the top right of the menu page, and checking the CSS Classes field. Then expand your menu item, and give it that menu-item-float-right class.
Try using ContextMenuStrip and add ToolStripMenuItems to it.
If you have to use MenuItem, you will have to do it through the DrawItem event with the OwnerDraw property set to true.
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