Tree View Design help

R

Ram

The below code is the code for my tree view.

Private Sub UserForm_Initialize()
Dim nodX As Node
Dim i As Long
Dim j As Long
Dim k As Long
Dim l As Long
Dim m As Long
Dim n As Long
TreeView1.CheckBoxes = False
With TreeView1.Nodes
.Clear

'Certifacte Name
Set nodX = .Add(, , "CName",
Worksheets("Cert_Details").Range("C_Name").Value)

'Path Name

Set nodX = .Add("CName", tvwChild, "Path",
Worksheets("Cert_Path_module").Range("Path").Value)
nodX.Expanded = True
End With

'Modules (1-5)
With Worksheets("Cert_Path_module")
For i = 1 To 5
With .Range("Module_" & i)
If .Value <> "" Then
Set nodX = TreeView1.Nodes.Add("Path", tvwChild, "Mod" &
i, .Value)
End If
End With
Next


End With
nodX.Expanded = True

'Learning Items
With Worksheets("Learning Item1")
For j = 1 To 20
With .Range("LI_" & j)
If .Value <> "" Then
Set nodX = TreeView1.Nodes.Add("Mod1", tvwChild, "LI_" &
j, .Value)
End If
End With
Next j
End With
nodX.Expanded = False

With Worksheets("Learning Item2")
For k = 1 To 20
With .Range("LI2_" & k)
If .Value <> "" Then
Set nodX = TreeView1.Nodes.Add("Mod2", tvwChild, "LI2_" &
k, .Value)
End If
End With
Next
End With
nodX.Expanded = False

With Worksheets("Learning Item3")
For l = 1 To 20
With .Range("LI3_" & l)
If .Value <> "" Then
Set nodX = TreeView1.Nodes.Add("Mod3", tvwChild, "LI3_" &
l, .Value)
End If
End With
Next
End With
nodX.Expanded = False

With Worksheets("Learning Item4")
For m = 1 To 20
With .Range("LI4_" & m)
If .Value <> "" Then
Set nodX = TreeView1.Nodes.Add("Mod4", tvwChild, "LI4_" &
m, .Value)
End If
End With
Next
End With
nodX.Expanded = False

With Worksheets("Learning Item5")
For n = 1 To 20
With .Range("LI5_" & n)
If .Value <> "" Then
Set nodX = TreeView1.Nodes.Add("Mod5", tvwChild, "LI5_" &
n, .Value)
End If
End With
Next
End With
nodX.Expanded = False

nodX.EnsureVisible

TreeView1.Style = tvwTreelinesPlusMinusText
TreeView1.BorderStyle = ccFixedSingle

End Sub


Now On clicking on each node, I want the node Value to be displayed in
text box 1. And the details of that node in Text box 2 (we get the
node details from the excel sheet). Is it possible to design such a
thing?
Note: Each node will have different values and different details .

Please suggest I'm using the tree view control for the firstime. I got
this idea from the tree view that you will fing in the following link.
http://puremis.net/excel/code/080.shtml

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top