关于treeview 中分级加载展开"+"问题

rkdrc 2019-12-02 11:32:22
public Function NodeLevel(ByVal n As TreeNode) As Byte
'* 找出树中当前节点的级数
Dim i As Byte = 1
'Dim m As String
Do Until n.Parent Is Nothing
n = n.Parent
i = i + 1
Loop
Return i
End Function
Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim SQLDB As New SQLDataBase(strConnect)
Dim strTable As New DataTable
Dim strProjectID As String = Split(SelectNodeID, "_")(1)

Select Case NodeLevel(e.Node).ToString
Case "1"
If e.Node.GetNodeCount(False) = 0 Then
strTable = SQLDB.ExecuteSQLToDataTable("Select * from tb_Matching_Region where Project_ID='" & strProjectID & "'")
For i As Integer = 0 To strTable.Rows.Count - 1
Dim tree_leaf As New TreeNode()
tree_leaf.Tag = strTable.Rows(i)("Matching_Region_ID").ToString()
tree_leaf.Text = strTable.Rows(i)("Matching_Name").ToString()
TreeView1.SelectedNode.Nodes.Add(tree_leaf)
Next
End If
Case "2"
If e.Node.GetNodeCount(False) = 0 Then
strTable = SQLDB.ExecuteSQLToDataTable("Select * from tb_Matching_Part where Matching_Region_ID='" & e.Node.Tag & "'")
For i As Integer = 0 To strTable.Rows.Count - 1
Dim tree_leaf As New TreeNode()
tree_leaf.Tag = strTable.Rows(i)("Matching_Part_ID").ToString()
tree_leaf.Text = strTable.Rows(i)("Part_ID").ToString()
TreeView1.SelectedNode.Nodes.Add(tree_leaf)
Next
End If
End Select
End Sub
以上属于分层加载功能,但存在一个问题,就是不显示“+”,只有单击某个节点后才能知道到底有没有下一级内容,如何自动加载子层级加号
...全文
173 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rkdrc 2019-12-04
  • 打赏
  • 举报
回复
这好像不解决
良朋 2019-12-03
  • 打赏
  • 举报
回复
this.treeView1.Nodes.Clear();
this.treeView1.BeginUpdate();

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧