Hi,
I was working with an application and faced this problem, I have this code :
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
contextMenuStrip1.Show(this, Control.MousePosition); // Or any other overload
}
}
private void Form2_Load(object sender, EventArgs e)
{
notifyIcon1.Icon = Icon;
}
}
Here, in design mode, i have set contextMenuStrip1 as notifyIcon1's ContextMenuStrip. When I right click on notifyIcon1, it opens the context menu and when I click somewhere else, it closes. But with my code opens the contextmenu on left click and when I open context menu that way, it shows in taskbar and doesn't close when I click some where else.
In short, I want to open contextmenustrip when user left clicks and right clicks on the notifyicon and it works well with right click by default but not with left click. And I want to avoid using SendMessage to send left click message.
Is there any way I can work this out?
I was working with an application and faced this problem, I have this code :
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
contextMenuStrip1.Show(this, Control.MousePosition); // Or any other overload
}
}
private void Form2_Load(object sender, EventArgs e)
{
notifyIcon1.Icon = Icon;
}
}
Here, in design mode, i have set contextMenuStrip1 as notifyIcon1's ContextMenuStrip. When I right click on notifyIcon1, it opens the context menu and when I click somewhere else, it closes. But with my code opens the contextmenu on left click and when I open context menu that way, it shows in taskbar and doesn't close when I click some where else.
In short, I want to open contextmenustrip when user left clicks and right clicks on the notifyicon and it works well with right click by default but not with left click. And I want to avoid using SendMessage to send left click message.
Is there any way I can work this out?