TreeView1.nodes.Add中提示集合中的关键字不唯一?(难!无人能解决)[提供源码附件]
以下代码:Private Sub CC()
OpenConn
Dim rs As Recordset
Dim m
Dim SQL
Dim nodes As Node
'TreeView1.LineStyle = tvwTreeLines
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select * from CC", cn, 2, 2
Dim i As Integer
Dim j As Integer
Dim zxs
TreeView1.ImageList = TreeImages
With rs
'RS.Close
' Set RS = Nothing
If .RecordCount <> 0 Then
For j = 0 To 5
.Close
.Open "select * from CC", cn, 2, 2
For i = 1 To .RecordCount
If .Fields("treerelationship") <> "" Then
TreeView1.nodes.Add CStr(.Fields("treerelative")), tvwChild, .Fields("treekey"), .Fields("用户姓名"), CInt(.Fields("treeimgindex"))
Else
TreeView1.nodes.Add , , .Fields("treekey"), .Fields("用户姓名"), CInt(.Fields("treeimgindex")) '此处提示集合中的关键字不唯一
End If
.MoveNext
Next i
Next j
End If
End With
For m = 1 To TreeView1.nodes.Count
TreeView1.nodes(m).Expanded = True '
Next
CloseConn
End Sub
Access数据库中数据如下:
TreeRelative TreeRelationship TreeKey 用户姓名 TreeIMGIndex
空 空 CC 在线用户 1
CC 1 张三 张三 1
CC.rar
(12.14 KB)
提供源码附件[ 本帖最后由 xzqsml 于 2010-1-23 11:56 编辑 ]