Hi, how to use a TreeView as a menu for making form visible. Eksampel: when i double click at a child node then i want something to happen. but how?
plizzz help <3

private void MyTree_DoubleClick(object sender, EventArgs e)
        {
            // 1st newbie way, easy way but the problem is with same names ...
            switch (MyTree.SelectedNode.Text.ToString())
            {
                case "Node 1":
                    MessageBox.Show("I am node 1");
                    break;
                case "Node 2":
                    MessageBox.Show("I am node 2");
                    break;
            }

            // 2nd way, right way but  and bit hard, you must remember indexs
            // carefully here, because nodes have unique Index, but childs have same
            // child of Node 1 have same index with child of Node 2,3..etc, so you have to 
            // say to program wich Node you want MyTree.Nodes[x]
            switch (MyTree.Nodes[1].Index)
            { 
                case 0:
                    MessageBox.Show("Emo...");
                    break;
        
                case 1:
                    break;
                
                case 2:
                    break;
                    
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.