Focus to node in treeview

  • Thread starter Thread starter Rasmus
  • Start date Start date
R

Rasmus

I need to grab focus to a specific node i my treeview when I click on my listbox.
Here's the code that differs between the different event i the listBox:

private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selected;
selected = this.listBox1.SelectedItem.ToString();

if(selected == "Error in Supercell 1")
{
this.treeView.Focus();
//here I would like to select a specific node i the treeView
}
if(selected == "Error in Job 1")
{
this.treeView.Focus();
}
if(selected == "Error in Welds")
{
this.treeView.Focus();
}
if(selected == "Error in Weld 1222")
{
this.treeView.Focus();
}
}

Any ideas.

Greetings Rasmus Madsen
 
you can use SelectedNode. assign it to the node you want to select:
this.treeView1.SelectedNode = mynode;

thanks,
Mohamed


--------------------
 
Back
Top