在线等....VB treeview的checkbox
原来用控件数组写的checkbox现在想把它加到treeview该怎么改写?本人没用过treeview..PrivateSubCheck1_Click(IndexAsIn...
原来用控件数组写的checkbox 现在想把它加到treeview 该怎么改写?
本人没用过treeview..
Private Sub Check1_Click(Index As Integer)
Dim i As Integer
For i = Check1.LBound To Check1.UBound
If Check1(i).Value = 1 Then
Label14.Enabled = True
Exit For
End If
Next
If i = Check1.UBound + 1 Then Label14.Enabled = False
End Sub
这个是原来的checkbox代码
现在让它变成treeview里的checkbox
逻辑要一样..
具体里面节点内容你们自己加把 随便的 不需要子节点的 给个完整的代码上来 谢
能不能给个完整的代码.. treeview里的checkbox 该怎么表示? 展开
本人没用过treeview..
Private Sub Check1_Click(Index As Integer)
Dim i As Integer
For i = Check1.LBound To Check1.UBound
If Check1(i).Value = 1 Then
Label14.Enabled = True
Exit For
End If
Next
If i = Check1.UBound + 1 Then Label14.Enabled = False
End Sub
这个是原来的checkbox代码
现在让它变成treeview里的checkbox
逻辑要一样..
具体里面节点内容你们自己加把 随便的 不需要子节点的 给个完整的代码上来 谢
能不能给个完整的代码.. treeview里的checkbox 该怎么表示? 展开
3个回答
展开全部
使用6.0版的Common Control(Microsoft Windows Common Controls 6.0)有这个功能
在窗体上画个Treeview,设置CheckBoxes=True
然后在Treeview_NodeCheck里写代码就行了,里面的Node就是被复选的节点
============代码==============
Private Sub Form_Load()
For i = 1 To 100
TreeView1.Nodes.Add , , , "节点" & i
Next
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
'在这里写上checkbox的处理代码
End Sub
==========================
如果想好看就点就设置FullRowSelect=True
在窗体上画个Treeview,设置CheckBoxes=True
然后在Treeview_NodeCheck里写代码就行了,里面的Node就是被复选的节点
============代码==============
Private Sub Form_Load()
For i = 1 To 100
TreeView1.Nodes.Add , , , "节点" & i
Next
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
'在这里写上checkbox的处理代码
End Sub
==========================
如果想好看就点就设置FullRowSelect=True
展开全部
建一个Treeview1,Label1.
代码如下。
==========
Private Sub Form_Load()
TreeView1.Checkboxes = True
For i = 1 To 100
TreeView1.Nodes.Add , , , "节点" & i
Next
End Sub
Private Sub TreeView1_Click()
Dim i As Integer
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Checked = True Then Label1.Enabled = True: Exit Sub
Next
Label1.Enabled = False
End Sub
代码如下。
==========
Private Sub Form_Load()
TreeView1.Checkboxes = True
For i = 1 To 100
TreeView1.Nodes.Add , , , "节点" & i
Next
End Sub
Private Sub TreeView1_Click()
Dim i As Integer
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Checked = True Then Label1.Enabled = True: Exit Sub
Next
Label1.Enabled = False
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
TreeView1.LineStyle = tvwRootLines
TreeView1.Style = tvwTreelinesPlusMinusText
TreeView1.LabelEdit = tvwManual
n = rs.RecordCount
Dim a As Date
Dim b As String
rs.MoveFirst
For i = 1 To n
a = rs.Fields("BillDate")
b = rs.Fields("BillAmount")
c = Str(a) & ".....$" & Format(b, "###,###.##")
Set nodx = TreeView1.Nodes.Add(, , c, c)
rs.MoveNext
Next i
TreeView1.Style = tvwTreelinesPlusMinusText
TreeView1.LabelEdit = tvwManual
n = rs.RecordCount
Dim a As Date
Dim b As String
rs.MoveFirst
For i = 1 To n
a = rs.Fields("BillDate")
b = rs.Fields("BillAmount")
c = Str(a) & ".....$" & Format(b, "###,###.##")
Set nodx = TreeView1.Nodes.Add(, , c, c)
rs.MoveNext
Next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询