遍历PB的TreeView的函数(转)
时间:2011-02-16 来源:quietwalk
Long li_cnt, ll_hdl[]
TreeViewItem lt_tvi
li_cnt = 1
ll_hdl[1] = tv_tree.FindItem(RootTreeItem!, 0)
Do While li_cnt > 0
If tv_tree.GetItem(ll_hdl[li_cnt], lt_tvi) = -1 Then Return -1
If findby Then
If lt_tvi.data = data Then
Return ll_hdl[li_cnt]
End If
Else
If lt_tvi.label = String(data) Then
Return ll_hdl[li_cnt]
End If
End If
If lt_tvi.children Then
li_cnt ++
ll_hdl[li_cnt] = tv_tree.FindItem( ChildTreeItem!, ll_hdl[li_cnt - 1])
Else
ll_hdl[li_cnt] = tv_tree.FindItem( NextTreeItem!, ll_hdl[li_cnt])
End If
Do While ll_hdl[li_cnt] <= 0
li_cnt --
If li_cnt = 0 Then Exit
ll_hdl[li_cnt] = tv_tree.FindItem( NextTreeItem!, ll_hdl[li_cnt])
Loop
Loop
Return 0