.net – 如何向System.Windows.Forms.MenuItem添加图标?
发布时间:2020-12-14 02:13:07 所属栏目:Windows 来源:网络整理
导读:我试图在我的一个上下文菜单项中添加一个图标,但我无法做到.有谁能够帮我? 这是我写的代码: private System.Windows.Forms.ContextMenu notifyContextMenu; private void foo() { if (notifyIcon == null) { notifyIcon = new System.Windows.Forms.Notify
我试图在我的一个上下文菜单项中添加一个图标,但我无法做到.有谁能够帮我?
这是我写的代码: private System.Windows.Forms.ContextMenu notifyContextMenu; private void foo() { if (notifyIcon == null) { notifyIcon = new System.Windows.Forms.NotifyIcon(); } if (notifyContextMenu == null) { notifyContextMenu = new System.Windows.Forms.ContextMenu(); notifyContextMenu.MenuItems.Add("Exit"); // How do I add an icon to this context menu item? } notifyIcon.ContextMenu = notifyContextMenu; } } 解决方法
MainMenu / ContextMenu已过时,您应该使用菜单条类.
更改 notifyContextMenu = new System.Windows.Forms.ContextMenu(); notifyContextMenu.MenuItems.Add("Exit"); 至 notifyContextMenu = new System.Windows.Forms.ContextMenuStrip(); var exitMenuItem = notifyContextMenu.Items.Add("Exit"); exitMenuItem.Image = ...; http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripitem.image.aspx 最后附上上下文菜单条来通知图标, notifyIcon.ContextMenuStrip = notifyContextMenu; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 以编程方式在R Console中设置字体和字体大小?
- 使用Windows XP SP3的远程WMI
- windows – RC2247:无法打开Rc文件:资源管理器无法加载资
- windows-7 – Windows 7笔记本电脑停滞,等待硬盘
- 条件转发器上的警告图标在Windows DNS管理器中的含义是什么
- Windows – sox FAIL util:无法加载MAD解码器库(libmad)函
- DLL符号_FooBar @ 16中的数字16代表什么?
- 窗口 – 什么时候可以使用PowerShell超过传统的应用程序?
- uwp – 对Microsoft Store API的请求始终返回空的产品/订阅
- windows-7 – 黑莓模拟器屏幕刷新
推荐文章
站长推荐
- windows-phone-7 – 如何在Windows Phone 7中获取
- 来自Windows Phone应用程序的PayPal交易
- windows-7 – Windows 7命令行提示符
- windows7 64位python pip安装错误:无法找到vcva
- windows-server-2008 – 针对AD Server 2008和20
- windows-server-2003 – 在野外使用Microsoft DN
- win10家庭版升级专业版出现0x80070422错误
- Windows下Mongodb安装部署
- msmq – 有没有办法只查看计算机管理的消息队列部
- 如何在Windows窗体C#中为文本框设置Scintilla
热点阅读