Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

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

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:

private void treeView1_Click( object sender, EventArgs e )
{
  treeView1.SelectedNode =
    treeView1.GetNodeAt( treeView1.PointToClient( Cursor.Position ) );
}

Contributed from George Shepherd's Windows Forms FAQ



Page view counter