如何把一个图标的菜单项 [英] How to put an icon in a MenuItem

查看:95
本文介绍了如何把一个图标的菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法把旁边的图标,文字的菜单项?

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(因此要求我彻底划清菜单项自己,就像是在这个例子中完成的:<一href="http://www.$c$cproject.com/KB/menus/cs_menus.aspx">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.

这篇关于如何把一个图标的菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆