问题描述
我的 Visual Studio 解决方案中有 2 个项目。第一个项目(Winforms/Application)有一个通知图标,内容菜单条如下所示:
private void TrayMenuContext()
{
notifyIcon1.ContextMenuStrip = new ContextMenuStrip();
notifyIcon1.ContextMenuStrip.Items.Add("Test1",null,MenuTest1_Click);
notifyIcon1.ContextMenuStrip.Items.Add("Test2",MenuTest2_Click);
notifyIcon1.ContextMenuStrip.Items.Add("Exit",MenuExit_Click);
}
private void notifyIcon1_MouseClick(object sender,MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
var mi = typeof(NotifyIcon).getmethod("ShowContextMenu",BindingFlags.Instance | BindingFlags.NonPublic);
mi?.Invoke(notifyIcon1,null);
}
}
第二个项目(Winforms/Application)有一个这样的按钮:
private void button1_Click(object sender,EventArgs e)
{
/*
* How should I code here to delete the notify icon content menu strip item
* in first application named "Test2"?
*/
}
当我单击按钮时,我想删除第一个应用程序通知图标内容菜单条中的“Test2”菜单项。但不幸的是,我对此一无所知。而且,我不知道这样的事情是否可能。然而,.Net 的非凡功能鼓励我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)