We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to Syncronize a button click event and cursor position on a node in treeViewAdv?

 

When the button is clicked ,the mouse cursor can be positioned appropriately on the respective node by getting the coordinates of the TreeNodeAdv by using PointToScreen method of treeViewAdv.

C#

//Provides the coordinates of the top-left corner of a TreeNodeAdv in terms of screen coordinates.

private Point MousePointer(TreeNodeAdv node)

{

Point point = this.treeViewAdv1.PointToScreen(this.treeViewAdv1.NodeToPoint(node));

point = new Point (point.X+node.NodeX, point.Y);

return point;

}

//Coding for the cursor position on a node when a button is clicked.

private void button1_Click(object sender, System.EventArgs e)

{

Cursor.Position = this.MousePointer (this.treeViewAdv1.Nodes[0]);

}

VB

'Provides the coordinates of the top-left corner of a TreeNodeAdv in terms of screen coordinates.

Private Function MousePointer(ByVal node As TreeNodeAdv) As Point

Dim point As Point = Me.treeViewAdv1.PointToScreen(Me.treeViewAdv1.NodeToPoint(node))

point = New Point (point.X+node.NodeX, point.Y)

Return point

End Function

'Coding for the cursor position on a node when a button is clicked.

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Cursor.Position = Me.MousePointer (Me.treeViewAdv1.Nodes(0))

End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
1361 04/30/2011 07/10/2014 Windows Forms TreeViewAdv
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.