Live Chat Icon For mobile
Live Chat Icon

How can I ensure that a node is selected when the user clicks along the line of a node?

Platform: WinForms| Category: TreeView

A click event will be fired but a node will not be selected when the user clicks to the right of a node. This code snippets show how you can ensure that a node is selected in this scenario:


[C#]
private void treeView1_Click(object sender, System.EventArgs e)
{
	treeView1.SelectedNode = treeView1.GetNodeAt(treeView1.PointToClient(Cursor.Position));
}
[VB.NET]
Private  Sub treeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
	treeView1.SelectedNode = treeView1.GetNodeAt(treeView1.PointToClient(Cursor.Position))
End Sub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.