Declare Supplier_Cur Cursor for
SELECT distinct parentid FROM 表名;
Open Supplier_Cur;
Fetch Supplier_Cur Into :ls_parentid ;
Do While SQLCA.sqlcode =0
ltvi.label =ls_parentid
ltvi.data =ls_parentid
ltvi.pictureindex =1
ltvi.selectedpictureindex =4
ltvi.children =true
tv_1.insertitemlast(0, ltvi)
Fetch Supplier_Cur Into :ls_parentid ;
Loop
Close Supplier_Cur;
再在TreeView的itempopulate事件中写
if handle >0 then
this.getitem(handle, l_tvi)
if l_tvi.level <> 1 then return
ls_parentid =string(l_tvi.data)
Declare Supplydate_Cur Cursor for
select id,name FROM 表名 WHERE parentid =:ls_parentid;
Open Supplydate_Cur;
Fetch Supplydate_Cur Into :ls_id,ls_name;
Do While SQLCA.sqlcode =0
ltvi.label =ls_name
ltvi.data =ls_id
ltvi.pictureindex =2
ltvi.selectedpictureindex =3
ltvi.children =false
tv_1.insertitemlast(handle, ltvi)
Fetch Supplydate_Cur Into :ls_id,ls_name;
Loop
Close Supplydate_Cur;
end if