有没有办法把旁边的图标,文字的菜单项?
Is there a way to put an icon next to the text in a MenuItem?
我用下面的code,显示弹出菜单,当用户在用户控制权点击:
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));
我想提出一个图标,以测试字符串左边的弹出式菜单,使用户更容易地识别它。有没有办法做到这一点以外的OwnerDraw属性设置为true(因此要求我彻底划清菜单项自己,就像是在这个例子中完成的:http://www.$c$cproject.com/KB/menus/cs_menus.aspx)?
任何帮助是AP preciated。
Any help is appreciated.
尝试使用的ContextMenuStrip并添加ToolStripMenuItems吧。
Try using ContextMenuStrip and add ToolStripMenuItems to it.
如果你必须使用菜单项,您将不得不通过DrawItem事件的OwnerDraw属性设置为true,做到这一点。
If you have to use MenuItem, you will have to do it through the DrawItem event with the OwnerDraw property set to true.