开发者

how to get the value of the selected child[0] node in tree view

How to get开发者_开发技巧 the value of the selected child[0] node in TreeView?

 parent
|->Child  index[0]
   |->Sub Child 
       |->Child (for sub child)
 parent
|->Child  index[1]
   |->Sub Child 
       |->Child (for subchild)

treeView1.SelectedNode returns only parent node selected value but I want to access the child when I will be select the child node then I want to add the subfield after the selected node.

I want to get the value of the child then add the subfield.

how to add the sub child nodes into the tree


I'm still not sure I fully understand you, but if all you need to do is get the selected value of any node in a treeview then the code below will work

public Form1()
    {
        InitializeComponent();
        TreeNode n1;
        TreeNode n2;
        TreeNode n3;
        n1 = treeView1.Nodes.Add("A");
        n2 = n1.Nodes.Add("B");
        n3 = n2.Nodes.Add("C");
        this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);


    }

    private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
    {
        TreeNode node = treeView1.SelectedNode;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜