I have 2 project in my solution on Visual Studio. First project (Winforms/Application) has got a notify icon with content menu strip like this:
private void TrayMenuContext()
{
notifyIcon1.ContextMenuStrip = new ContextMenuStrip();
notifyIcon1.ContextMenuStrip.Items.Add("Test1", null, MenuTest1_Click);
notifyIcon1.ContextMenuStrip.Items.Add("Test2", null, MenuTest2_Click);
notifyIcon1.ContextMenuStrip.Items.Add("Exit", null, 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);
}
}
And the second project (Winforms/Application) has got a button like this:
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"?
*/
}
When I click the button, I want to delete the "Test2" menu item in the first application notify icon content menu strip. But unfortunately I don't have the slightest idea about it. Moreover, I do not know if such a thing is possible. However, the extraordinary features of .Net encourage me.