开发者

Open Context Menu On Selected TreeView Node

What is the problem with this code ?

 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
          开发者_StackOverflow      Dim p As Point = New Point(e.X, e.Y)

                mnuRoot.Show(p)
            End If
        End Sub

the context menu does not open in right position.


The ContextMenuStrip.Show(Point) overload requires the point to be in screen coordinates. Fix:

 mnuRoot.Show(trvHeader, p)

or use Control.PointToScreen()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜