Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tree walking routines... I hate them too.
Drop a TreeView control and a CommandButton control onto a UserForm then use this example code. Private Sub UserForm_Initialize() Dim nod As Node TreeView1.CheckBoxes = True With TreeView1.Nodes Set nod = .Add(Relationship:=tvwChild, Text:="A1") Set nod = .Add(Relative:=nod, Relationship:=tvwChild, Text:="A2") Set nod = .Add(Relative:=nod, Relationship:=tvwChild, Text:="A3") Set nod = .Add(Relationship:=tvwChild, Text:="B1") Set nod = .Add(Relative:=nod, Relationship:=tvwChild, Text:="B2") Set nod = .Add(Relative:=nod, Relationship:=tvwChild, Text:="B3") Set nod = .Add(Relationship:=tvwChild, Text:="C1") Set nod = .Add(Relative:=nod, Relationship:=tvwChild, Text:="C2") Set nod = .Add(Relative:=nod, Relationship:=tvwChild, Text:="C3") End With End Sub Private Sub CommandButton1_Click() Dim nod As Node, str As String If TreeView1.Nodes.Count 0 Then Set nod = TreeView1.Nodes(1) Do If nod.Checked Then str = str & IIf(str = "", "", ", ") & nod.Text If Not nod.Child Is Nothing Then Set nod = nod.Child ElseIf Not nod.Next Is Nothing Then Set nod = nod.Next Else Do Set nod = nod.Parent If Not nod Is Nothing Then If Not nod.Next Is Nothing Then Set nod = nod.Next Exit Do End If Else Exit Do End If Loop If nod Is Nothing Then Exit Do End If Loop MsgBox str End If End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Dan Thompson" wrote in message ... I am using the Treview form control on a userform. I have a Root node called "Root" and a Child Node Called "Charts" than I have child or grandchild nodes off of the "Charts" Node, 5 of them to be exact which are named "c1", "c2", "c3", "c4" and "c5". all of the nodes in my tree have empty check boxes beside the node name. What I would like to be able to do is to go through and check for example nodes "c2" and "c4" ect.. and then programaticly have vba return in a message box whcih nodes were checked. Any Ideas on how to do this ? Dan. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding nodes to treeview | Excel Programming | |||
Treeview control in an Excel form | Excel Programming | |||
Returning control to form | Excel Programming | |||
treeview add nodes | Excel Programming | |||
TreeView: add more than one node to nodes collection | Excel Programming |