# TreeView的问题

Posted by 巨蟹座女子 on February 15, 1998 at 22:19:21:

在根目录下有六层（r, Axx, Bxx,Cxx, Dxx, Exx, Fxx).
在Form Load 把Database资料读进来时, 出现错误(找不到元素).
请问是哪里出了错?
Set rsDir = myDB.OpenRecordset("目录名称", dbOpenDynaset)
Set nodX = TreeView1.Nodes.Add(, , "r", "\")
nodX.Image = "open"
rsDirectory.MoveFirst
'
Do Until rsDir.EOF
If rsDir!ParentID = "r" Then
Set nodX = TreeView1.Nodes.Add("r", tvwChild,
rsDir!ChildID, rsDir!Child, 1)
End If
rsDir.MoveNext
Loop
'
rsDir.MoveFirst
Do Until rsDir.EOF
If rsDir!ParentID "r" Then
Set nodX = TreeView1.Nodes.Add(CStr(rsDir!ParentID),
tvwChild,rsDir!ChildID, rsDir!Child, 1)
End If
rsDir.MoveNext
Loop
另外有一个问题：读进来的资料, 不是以Ascending 的方式呈现.
假设有一资料库如下, Data转成TreeView后, 不会依A to Z的顺序
排列. 请问要如何Sorting 呢?
---------------------------------------------------------------
| ParentID | Parent | ChildID | Child |
-----------------------------------------------------------------
| r | r | A01 | JPSD |
| r | r | A02 | TDWO |
| r | r | A03 | CSME |
| A02 | CSME | B01 | TX96 |
| A02 | CSME | B02 | TX58 |
| A01 | JPSD | B03 | NSX1 |
| B01 | TX96 | C01 | GHLX |
| B02 | TX58 | C02 | LKTF |
| A02 | CSME | B04 | AQTS |
| r | r | A04 | BTDS |
-----------------------------------------------------------------
\(Root)
|
|---- JPSD
| |
| ----- NSX1
|
|---- TDWO
| |
| ----- TX96
| | |
| | ----- GHLX
| |
| ----- TX58
| |
| ----- LKTF
|
|---- CSME
| |
| ----- AQTS
|
----- BTDS

Follow Ups:

- Re: TreeView的问题 小吴 17:13:43 2/16/98 (1)
  - 不太懂ㄝ 巨蟹座女子 19:44:17 2/16/98 (0)