Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView ?, Wanting to Traverse all children from selected Parent

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
Ok heres what I want to do, when I check a Node<br>and I want to be able to do something like a For each ...<br>changing all the child node to the check of the parent like someChild.checked = node.checked, but I also want to be able to get the children of the children(heiarchy will never exceed 3 levels Parent1-Node2-Node3 and will only be 2 or 3 level, but never a Root node alone)<br>Shape<br>&nbsp;&nbsp;¦-Sic4<br>or<br>Shape<br>&nbsp;¦-Sic2<br>&nbsp;&nbsp;&nbsp;¦-Sic4<br><br>(Just in case it matters in how I can make it enable the checkboxes on everything below it, like if I check a Shape, I want it to get all Sic2, Sic4, and Sic2+Sic4 below it, or if i check a Sic2 , Check all sic4 under it) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Karl,<br><br>Code below taken from help file.<br><br>If TreeView1.SelectedItem.Children &gt; 0 Then<br>' There are children.<br>' Get first child's text, and set N to its index value.<br>&nbsp;&nbsp;strC = TreeView1.SelectedItem.Child.Text & vbLF <br>&nbsp;&nbsp;N = TreeView1.SelectedItem.Child.Index<br>' While N is not the index of the child node's<br>' last sibling, get next sibling's text.<br>&nbsp;&nbsp;While N &lt;&gt; TreeView1.SelectedItem.Child.LastSibling.Index<br>&nbsp;&nbsp;&nbsp;&nbsp;strC = strC & TreeView1.Nodes(N).Next.Text & vbLF<br>&nbsp;&nbsp;&nbsp;&nbsp;' check this child<br>&nbsp;&nbsp;&nbsp;&nbsp;TreeView1.Nodes(N).Selected = True<br>&nbsp;&nbsp;&nbsp;&nbsp;' Reset N to next sibling's index.<br>&nbsp;&nbsp;&nbsp;&nbsp;N = TreeView1.Nodes(N).Next.Index<br>&nbsp;&nbsp;Wend<br>' Show results.<br>MsgBox &quot;Children of &quot; & TreeView1.SelectedItem.Text & _<br>&nbsp;&nbsp;&quot; are: &quot; & vbLF & strC<br>End If<br><br>Doesn't look too bad, should ok to do a recursive function that processes all children (children of children I mean) using these properties. Shout if you need a hand with that.<br><br>Mike <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top