Welcome Guest Search | Active Topics | Members | Log In | Register

Finding Child text Options
yoda
Posted: Tuesday, April 20, 2010 3:21:35 PM
Rank: Newbie

Joined: 4/20/2010
Posts: 1
Points: 3
Location: San Diego
I have been stuck for a few days and need advise. When the user selects a node I want to display the text of the childeren.

Sample code:

Private Sub TreeView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.Click

TextBox1.Text = ""

TextBox1.Text = "Level = " & TreeView1.SelectedNode.Level
TextBox1.Text = TextBox1.Text & vbCrLf & "Index = " & TreeView1.SelectedNode.Index
TextBox1.Text = TextBox1.Text & vbCrLf & "Text = " & TreeView1.SelectedNode.Text

If TreeView1.SelectedNode.Level = 0 Then

TextBox1.Text = TextBox1.Text & vbCrLf & "Text = " & ??????????I NEED TO KNOW WHAT TO PUT HERE FOR THE CHILDREN

End If


End Sub
LidorSystems Support
Posted: Tuesday, April 20, 2010 4:18:24 PM

Rank: Administration

Joined: 6/10/2005
Posts: 637
Points: 1,365
Just cycle through child nodes for selected node and add their text. Here is how:

Code:
If TreeView1.SelectedNode.Level = 0 Then
   For Each node As LidorSystems.IntegralUI.Lists.TreeNode In TreeView1.SelectedNode.Nodes
      TextBox1.Text = TextBox1.Text & vbCrLf & vbTab & "Text = " & node.Text
   Next
End If


If the child nodes also have their own child nodes, then use a method:

Code:
ShowChildren(TreeView1.SelectedNode)

Code:
Private Sub ShowChildren(ByVal parentNode As LidorSystems.IntegralUI.Lists.TreeNode)
   For Each node As LidorSystems.IntegralUI.Lists.TreeNode In parentNode.Nodes
      TextBox1.Text = TextBox1.Text & vbCrLf

      For i As Integer = 0 To parentNode.Level
         TextBox1.Text = TextBox1.Text & vbTab
      Next

      TextBox1.Text = TextBox1.Text & "Text = " & node.Text
     
      ShowChildren(node)
   Next
End Sub



Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.0 (NET v2.0) - 10/10/2006
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.138 seconds.