Immediate children in a tree view.

2 posts, 0 answers
  1. Nen
    Nen avatar
    7 posts
    Member since:
    Oct 2010

    Posted 21 Oct 2010 Link to this post

    Hi all,

    how do i find the immdiate children of a parent node???, is this supported by telerik?

    Thanks
    -Nen
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Oct 2010 Link to this post

    Hello Nen,

    Try the following code snippet to access first child node of a parent node .

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server">
               <Nodes>
                   <telerik:RadTreeNode Text="Books">
                       <Nodes>
                           <telerik:RadTreeNode Text="Arts" Expanded="false">
                               <Nodes>
                                   <telerik:RadTreeNode Text="Children's Music" />
                                   <telerik:RadTreeNode Text="Classical" />
                               </Nodes>
                           </telerik:RadTreeNode>
                           <telerik:RadTreeNode Text="Biographies" />
                       </Nodes>
                   </telerik:RadTreeNode>
               </Nodes>
           </telerik:RadTreeView>

    C#:
    RadTreeNode node = RadTreeView1.FindNodeByText("Books"); // access parent node
    RadTreeNode childNode = node.Nodes[0];// access first child node


    Otherwise, use the following code:

        RadTreeView1.Nodes[0].Nodes[0].Text


    -Shinu.
Back to Top