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 enable support for selecting a node in a TreeView when it is right-clicked?

Handle the TreeView's MouseDown event, and if it is the right-click, then explicitly set focus to the node under the click.

private void treeView1_MouseDown( object sender, MouseEventArgs e )
{
  if ( e.Button == MouseButtons.Right )
    treeView1.SelectedNode = treeView1.GetNodeAt ( e.X, e.Y );
}

Contributed from George Shepherd's Windows Forms FAQ



Page view counter