求助高手,WPF ContextMenu MenuItem的icon设置成透明,或者去掉icon
2个回答
2015-07-18
展开全部
NotifyIcon里面有一个ContextMenuStrip属性,直接设置这个属性就可以了,不要在click事件中设置,这是我以前写的一个项目中截的,粘给你看看:
System.Windows.Forms.ContextMenuStrip contextMenu = new System.Windows.Forms.ContextMenuStrip();
System.Windows.Forms.ToolStripMenuItem item1 = new System.Windows.Forms.ToolStripMenuItem();
item1.Click += new EventHandler(item1_Click);
item1.Text = "显示主面板";
System.Windows.Forms.ToolStripMenuItem item2= new System.Windows.Forms.ToolStripMenuItem();
item2.Text = "退出";
item2.Click += new EventHandler(item2_Click);
contextMenu.Items.Add(item1);
contextMenu.Items.Add(item2);
this.notifyIcon.ContextMenuStrip = contextMenu;
System.Windows.Forms.ContextMenuStrip contextMenu = new System.Windows.Forms.ContextMenuStrip();
System.Windows.Forms.ToolStripMenuItem item1 = new System.Windows.Forms.ToolStripMenuItem();
item1.Click += new EventHandler(item1_Click);
item1.Text = "显示主面板";
System.Windows.Forms.ToolStripMenuItem item2= new System.Windows.Forms.ToolStripMenuItem();
item2.Text = "退出";
item2.Click += new EventHandler(item2_Click);
contextMenu.Items.Add(item1);
contextMenu.Items.Add(item2);
this.notifyIcon.ContextMenuStrip = contextMenu;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询