In TreeView We need to Do any operation when a node clicked or selected.We can't trigger an event with the name of Node. We have to do it by triggering Tree Views Event.In this example i am used 'NodeMouseClick' Event.
1. Add a TreeView Control to your Form.
2. Add the Needed Nodes .
3. Now Double Click on TreeViews 'NodeMouseClick' Event.
4. Now Compare with Node.Name or Node.Text in the Event.just see the Code below.
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
// Compare By Node.Name
if (e.Node.Name == "NodeJava")
{
MessageBox.Show("JAVA");
}
//Or
// Compare By Node.Text
if (e.Node.Text == "C#")
{
MessageBox.Show("C#");
}
}
Checkout and Do Comment Here..
Exelente, esto era lo que buscaba
ReplyDelete