Function for traversing the Treeview OF Pb

Source: Internet
Author: User

/*
because PB's Treeview control does not provide the search item function, this Program is a supplement to this shortcoming.
call Syntax:
findtreeitem (TV _tree, findby, data)
call parameters:
TV _tree: Treeview, specify search in the TV _tree tree
findby: Boolean, specify the search method
false-label) search
true-search by additional data
data: Any, specify the content to be searched
return value: long type. If it is found, return the handle of the found item;
if it is not found, return 0;
if an error occurs, back to-1
*/

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.