Focus to node in treeview

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
 
M

Mohamed Enein

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

thanks,
Mohamed


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top