Private Sub Form_Load()
Rs1.CommandType = adCmdText
Rs1.RecordSource = "select distinct biao,zu from test order by zu"
Rs1.Refresh
Dim Rs As ADODB.Recordset
Set Rs = Rs1.Recordset Set nodX = TreeView1.Nodes.Add(, , "r", "报表组 ")
i = 0
Dim TempString As String
Dim TempKey As Long
Do Until Rs.EOF Or Rs.BOF
If TempString = Rs!zu Then
Set nodeX = TreeView1.Nodes.Add("Z" & TempKey, tvwChild, "B" & i, Rs!biao)
Else
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "Z" & i, Rs!zu)
Set nodeX = TreeView1.Nodes.Add("Z" & i, tvwChild, "B" & i, Rs!biao)
TempString = Rs!zu
TempKey = i
End If
Rs.MoveNext
i = i + 1
Loop
End Sub其中zu相当于parentid
biao相当于id
Rs1.CommandType = adCmdText
Rs1.RecordSource = "select distinct biao,zu from test order by zu"
Rs1.Refresh
Dim Rs As ADODB.Recordset
Set Rs = Rs1.Recordset Set nodX = TreeView1.Nodes.Add(, , "r", "报表组 ")
i = 0
Dim TempString As String
Dim TempKey As Long
Do Until Rs.EOF Or Rs.BOF
If TempString = Rs!zu Then
Set nodeX = TreeView1.Nodes.Add("Z" & TempKey, tvwChild, "B" & i, Rs!biao)
Else
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "Z" & i, Rs!zu)
Set nodeX = TreeView1.Nodes.Add("Z" & i, tvwChild, "B" & i, Rs!biao)
TempString = Rs!zu
TempKey = i
End If
Rs.MoveNext
i = i + 1
Loop
End Sub其中zu相当于parentid
biao相当于id
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货