2017-05-06 68 views
0

如果我在TreeView(而不是單個節點)上的某處執行右鍵單擊,我想要彈出一個上下文菜單。C#相對於應用程序的光標位置

這種有點作品,但菜單彈出了點擊位置的方式。 我用這個技巧HERE試過了,但它不起作用。

這是我的代碼和scrrenshot。有任何想法嗎 ?

private void Mainform_TreeView_MouseDown(object sender, MouseEventArgs e) 
    { 
     contextMenuStrip1.Show(PointToClient(Cursor.Position)); 
    } 

enter image description here

回答

0

啊......接受只有一個點預計屏幕COORDS,所以你只需要過載:

contextMenuStrip1.Show(Cursor.Position);