CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 1999
    Location
    TAiwan
    Posts
    7

    How to select a node that I just added in a TreeView?

    Dear all,
    I want to make the node which I just added in the treeview selected. Can anyone tell me how to do that??

    Thanks in advance.

    Eddie
    Last edited by Eddie Lin; May 23rd, 2002 at 12:47 AM.

  2. #2
    Join Date
    Sep 2001
    Location
    San Diego
    Posts
    2,147
    tree.Nodes.Add("Parent");
    tree.Nodes[0].Nodes.Add("Child 1");
    tree.Nodes[0].Nodes.Add("Child 2");
    tree.Nodes[0].Nodes[0].Nodes.Add("Grandchild 1"); // child of child 1

    Then:

    tree.SelectedNode = tree.Nodes[0].Nodes[1]; // select Child 2

    -or-

    TreeNode MyNode = tree.Nodes[0].Nodes[1];
    tree.SelectedNode = MyNode;

    Hope this helps,

    - Nigel

  3. #3
    Join Date
    Oct 1999
    Location
    TAiwan
    Posts
    7
    Dear Nigel,
    I got it!! Thanks a lot!!

    Regards,
    Eddie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured