从 c# 中的另一个 exe 文件中删除 Notifyicon ContextMenuStrip 项目

问题描述

我的 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...