展开全部
1、前提条件:在窗体上添加一个ImageList控件(ImageList1),在ImageList1中添加图标并命名(方便使用),然后通过设置树状浏览器控件的ImageList属性为ImageList1将该控件与图像列表控件联系起来。
2、在树状浏览器控件的Collapse事件中添加代码,把节点的图像设置成关闭的文件夹:
Private Sub TreeView1_Collapse(ByVal Node As ComclLib.Node)
Node.Image="closed" 'closed是关闭图标的名称
End Sub
3、在树状浏览器控件的Expand事件中添加代码,把节点的图像设置成打开的文件夹:
Private Sub TreeView1_Collapse(ByVal Node As ComclLib.Node)
Node.Image="open" 'open是打开图标的名称
End Sub
2、在树状浏览器控件的Collapse事件中添加代码,把节点的图像设置成关闭的文件夹:
Private Sub TreeView1_Collapse(ByVal Node As ComclLib.Node)
Node.Image="closed" 'closed是关闭图标的名称
End Sub
3、在树状浏览器控件的Expand事件中添加代码,把节点的图像设置成打开的文件夹:
Private Sub TreeView1_Collapse(ByVal Node As ComclLib.Node)
Node.Image="open" 'open是打开图标的名称
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
TreeView1.LineStyle = tvwRootLines
TreeView1.LabelEdit = tvwManual
TreeView1.ImageList = ImageList1 'imagelist控件中有2个图标sq(收起)和zk(展开)
TreeView1.Nodes.Add , , "a", "A", "sq"
TreeView1.Nodes.Add "a", tvwChild, "b", "B"
TreeView1.Nodes.Add "a", tvwChild, "c", "C"
End Sub
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim nd As Node
For Each nd In TreeView1.Nodes
If nd.Expanded = True And nd.Children > 0 Then '展开
nd.Image = "zk"
ElseIf nd.Expanded = False And nd.Children > 0 Then '收起
nd.Image = "sq"
End If
Next
End Sub
TreeView1.LineStyle = tvwRootLines
TreeView1.LabelEdit = tvwManual
TreeView1.ImageList = ImageList1 'imagelist控件中有2个图标sq(收起)和zk(展开)
TreeView1.Nodes.Add , , "a", "A", "sq"
TreeView1.Nodes.Add "a", tvwChild, "b", "B"
TreeView1.Nodes.Add "a", tvwChild, "c", "C"
End Sub
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim nd As Node
For Each nd In TreeView1.Nodes
If nd.Expanded = True And nd.Children > 0 Then '展开
nd.Image = "zk"
ElseIf nd.Expanded = False And nd.Children > 0 Then '收起
nd.Image = "sq"
End If
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询