質問

右クリックではなく、クリックされたときにトレイアイコンのコンテキストメニューを強制的に表示するにはどうすればよいですか。

MouseClickイベントを使用しようとしましたが、eventargsのマウス位置はx0y0です。

役に立ちましたか?

解決

これはあなたのためにそれを行う必要があります:

private void notifyIcon1_Click(object sender, EventArgs e)
        {
            contextMenuStrip1.Show(Cursor.Position.X, Cursor.Position.Y);
        }

他のヒント

もう少しうまくいくことがわかった別の方法:

private void notifyIcon1_MouseUp(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            System.Reflection.MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            mi.Invoke(notifyIcon1, null);
        }
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top