Live Chat Icon For mobile
Live Chat Icon

When I right-click a tree node, it does not become selected. How can I make it be selected on a right-click

Platform: WinForms| Category: TreeView

Handle the treeview’s mousedown event, and if it is the right-click, then explicitly set focus to th enode under the click.

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

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.