TreeView - click the Node and open specific screen

1

I have TreeView , with some configuration items:

I would like to double click on a node it opens a specific form, the event of double-clicking and opening the form, is OK, the problem is how do I distinguish a node from the other? >

When you double-click Users it opens the Users screen by double-clicking Permissions Permissions screen .

Event DoubleClick :

this.treeView1.NodeMouseDoubleClick += 
new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.TreeView1_doubleClick);

Method I am using to generate doubleclick :

private void TreeView1_doubleClick(Object sender, TreeNodeMouseClickEventArgs e)// clicar em usuarios     
{
     Manutencao_usuarios clickmu = new Manutencao_usuarios();
     clickmu.ShowDialog();
}
    
asked by anonymous 30.07.2016 / 14:54

1 answer

1

You can do this in the event NodeMouseDoubleClick of TreeView :

private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
    string node = e.Node.Text;
    switch (node)
    {
        case "Servidores e Diretórios":
            // Abrir o formulário Servidores e Diretórios
            break;
        case "Usuários":
            // Abrir o formulário Usuários
            break;

        // Restante do código...

        default:
            // Fazer algo se nenhuma das opções acima for clicada
            break;
    }
}
    
30.07.2016 / 15:17