2011-03-03 52 views
0

此代碼有什麼問題?在選定TreeView節點上打開上下文菜單

Private Sub trvHeader_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles trvHeader.NodeMouseClick 
      If e.Button = Windows.Forms.MouseButtons.Right Then 
       trvHeader.SelectedNode = e.Node 
       Dim p As Point = New Point(e.X, e.Y) 

       mnuRoot.Show(p) 
      End If 
     End Sub 

上下文菜單沒有在正確的位置打開。

回答

1

的ContextMenuStrip.Show(點)的過載需要指向在屏幕座標。修復:

mnuRoot.Show(trvHeader, p) 

或使用Control.PointToScreen()

相關問題