|
正在学树控件,用玄雨清风的方法一个一个节点添加学会了,用蓝色幻想的方法引用表格单元格学会了
Private Sub UserForm_Initialize()
Dim NodeX As Node
Set NodeX = TreeView1.Nodes.Add(, , "课程科目", "课程科目")
NodeX.BackColor = &HFFFFC0
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "语文", "语文")
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "数学", "数学")
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "外语", "外语")
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "政治", "政治")
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "物理", "物理")
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "化学", "化学")
Set NodeX = TreeView1.Nodes.Add("课程科目", tvwChild, "生物", "生物")
Dim i As Long
For i = 2 To TreeView1.Nodes.Count
TreeView1.Nodes(i).BackColor = &HFF&
Next i
'TreeView2.ImageList = ImageList1
Set Nodx = TreeView2.Nodes.Add(, , "总行", "商业银行 网点:")
Nodx.BackColor = &HFF&
For X = 2 To [A65536].End(xlUp).Row
Text = Cells(X, "A")
Number = Cells(X, "B")
If Len(Cells(X, "B")) = 1 Then
Set Nodx = TreeView2.Nodes.Add("总行", tvwChild, "key" & Number, Number & " " & Text)
Nodx.BackColor = &HFFFF&
ElseIf Len(Cells(X, "B")) = 3 Then
Set Nodx = TreeView2.Nodes.Add("key" & Left(Number, 1), tvwChild, "key" & Number, Number & " " & Text)
Nodx.BackColor = &HFFFF00
ElseIf Len(Cells(X, "B")) = 5 Then
Set Nodx = TreeView2.Nodes.Add("key" & Left(Number, 3), tvwChild, "key" & Number, Number & " " & Text)
Nodx.BackColor = &HFF00FF
End If
Next
Set NodeX = Nothing
End Sub
但我最想学用“常数数组ARRAY”的方法添加节点,不引用表格单元格(不引用数据库数据),直接用代码,如本贴所示,看不懂,好象用到了ARRAY,如果要添加三级节点,根节点,子节点,孙节点,不知怎么用? |
|