DataTables("会计科目").loadtop = Nothing
DataTables("会计科目").loadfilter = "科目类型='损益'"
DataTables("会计科目").load()
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim rts() As String = {"损益"}
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("会计科目")
tr.StopRedraw()
tr.Nodes.Clear
Dim gz As String = "444"
For Each rt As String In rts
此主题相关图片如下:微信截图_20250121182246.png
tr.Nodes.Add(rt)
Next
For Each dr As DataRow In dt.Select("", "科目编码")
If dr.IsNull("科目编码") = False AndAlso dr("科目编码").Length = val(gz(0)) Then
Dim i As Integer = CInt(dr("科目编码").Substring(0, 1))
nd = tr.Nodes(i).Nodes.Add(dr("科目编码"), dr("科目编码") & " " & dr("科目名称"))
Functions.Execute("km", nd, dt, gz, 1)
End If
Next
tr.ResumeRedraw()
删除目录树节点名称为:资产、负债、成本、损益,代码怎样写
我想使用下面的代码,先生成目录树,再删除一、二级没有节点的目录树节点。这样就可以做到我选择哪类科目就加载哪类Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1") Dim rts() As String = {"全部", "资产"}
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("会计科目")
tr.StopRedraw()
tr.Nodes.Clear
Dim gz As String = "444"
For Each rt As String In rts
tr.Nodes.Add(rt)
Next
For Each dr As DataRow In dt.Select("", "科目编码")
If dr.IsNull("科目编码") = False AndAlso dr("科目编码").Length = val(gz(0)) Then
Dim i As Integer = CInt(dr("科目编码").Substring(0, 1))
nd = tr.Nodes(i).Nodes.Add(dr("科目编码"), dr("科目编码") & " " & dr("科目名称"))
Functions.Execute("km", nd, dt, gz, 1)
End If
Next
tr.ResumeRedraw()
放到最后
for i as integer = tr.Nodes.count - 1
if tr.Nodes(i).nodes.count = 0 then tr.Nodes(i).delete
next
语法错误
此主题相关图片如下:微信截图_20250122111605.png
DataTables("会计科目").loadtop = Nothing
DataTables("会计科目").loadfilter = "科目类型='资产'"
DataTables("会计科目").load()
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim rts() As String = {"全部", "资产"}
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("会计科目")
tr.StopRedraw()
tr.Nodes.Clear
Dim gz As String = "444"
For Each rt As String In rts
tr.Nodes.Add(rt)
Next
For Each dr As DataRow In dt.Select("", "科目编码")
If dr.IsNull("科目编码") = False AndAlso dr("科目编码").Length = val(gz(0)) Then
Dim i As Integer = CInt(dr("科目编码").Substring(0, 1))
nd = tr.Nodes(i).Nodes.Add(dr("科目编码"), dr("科目编码") & " " & dr("科目名称"))
Functions.Execute("km", nd, dt, gz, 1)
End If
Next
tr.ResumeRedraw()
for i as integer = tr.Nodes.count - 1 if tr.Nodes(i).nodes.count = 0 then tr.Nodes(i).delete next |
for i as integer = 0 TO tr.Nodes.count - 1
if tr.Nodes(i).nodes.count = 0 then tr.Nodes(i).delete
next
此主题相关图片如下:微信截图_20250122154701.png