0

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

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Panathinaikos22
1
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;
                    
            }
        }

Edited by Panathinaikos22: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.