ここにサンプルのC#ウィンドウフォームがあります。マウスを左クリックしたときに通知アイコンのコンテキストメニューを表示する必要があります。必要なコードをどこに書くかを以下のようにマークしました。
private void button1_Click(object sender, EventArgs e)
{
//Need to show the context menu here
}
助けてください!
ここにサンプルのC#ウィンドウフォームがあります。マウスを左クリックしたときに通知アイコンのコンテキストメニューを表示する必要があります。必要なコードをどこに書くかを以下のようにマークしました。
private void button1_Click(object sender, EventArgs e)
{
//Need to show the context menu here
}
助けてください!
アイコンを左クリックしたときにメニューを表示するには
private void NotifyIcon_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
MethodInfo methodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
methodInfo.Invoke(this.notifyIcon, null);
}
}
質問のボタンがクリックされたときにメニューを表示するには
private void button1_Click(object sender, EventArgs e)
{
//Need to show the context menu here
MethodInfo methodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
methodInfo.Invoke(this.notifyIcon, null);
}