VB treeview详解

怎么设置treenode?
2024-11-18 09:45:20
推荐回答(1个)
回答(1):

'新建一个窗体,上面放一个TreeView和一个ListView,一个ListImage
'ListImage控件要添加8张以上一样大小的icon文件
'TreeView1和ListView的图像列表都设置成ListImage1
Private Sub Form_Load()
TreeView1.Style = tvwTreelinesPlusMinusPictureText
TreeView1.LabelEdit = tvwManual
TreeView1.Checkboxes = True
ListView1.View = lvwIcon
ListView1.BorderStyle = ccFixedSingle

TreeView1.Nodes.Add , , "r", "学籍管理信息系统", 1
TreeView1.Nodes.Add "r", tvwChild, "r1", "学生基本信息", 2
TreeView1.Nodes.Add "r1", tvwChild, "r11", "个人信息", 3
TreeView1.Nodes.Add "r1", tvwChild, "r12", "家庭信息", 3
TreeView1.Nodes.Add "r", tvwChild, "r2", "学习成绩", 4
TreeView1.Nodes.Add "r2", tvwChild, "r21", "专业成绩", 5
TreeView1.Nodes.Add "r2", tvwChild, "r22", "英语成绩", 5
TreeView1.Nodes.Add "r", tvwChild, "r3", "社团活动", 6
TreeView1.Nodes.Add "r3", tvwChild, "r31", "政治面貌", 7
TreeView1.Nodes.Add "r3", tvwChild, "r32", "获奖情况", 7
For i = 1 To TreeView1.Nodes.Count
TreeView1.Nodes(i).Expanded = True
Next i
End Sub