|
不知道有没有直接设置的属性,全部展开就写一个循环好了
- Dim rng0 As Range
- Private Sub TreeView1_Click()
- With Me.TreeView1
- r = CInt(Right(.SelectedItem.Key, 3))
- rng0.Cells(r, 1).Activate
- End With
- End Sub
- Private Sub UserForm_Initialize()
- Set rng0 = Sheet1.Range("a3:c" & 99)
- ar = rng0.Value
- With Me.TreeView1
- .LineStyle = tvwRootLines
- .Nodes.Add , , "R000", "ROOT"
- For i = 2 To UBound(ar)
- If Len(ar(i, 1)) > 0 Then
- key1 = "R" & i + 1000
- .Nodes.Add "R000", tvwChild, key1, ar(i, 1)
- End If
- If Len(ar(i, 2)) > 0 Then
- key2 = "RR" & i + 1000
- .Nodes.Add key1, tvwChild, key2, ar(i, 2)
- End If
- If Len(ar(i, 3)) > 0 Then
- .Nodes.Add key2, tvwChild, "RRR" & 1000 + i, ar(i, 3)
- End If
- Next
- For Each Node In .Nodes
- Node.Expanded = True
- Next
- End With
- End Sub
复制代码 |
|