关闭

PB TreeView 控件实现查找功能

566人阅读 评论(0) 收藏 举报
分类:
long ll_handle,ll_level,ll_handletree[]
int li_find
string ls_find
treeviewitem ltvi_1

SetPointer(hourglass!)
tv_1.setredraw(false)
ls_find = sle_find.text
if trim(ls_find) = '' then 
	Messagebox("提示","请先输入查询条件!")
	return 
end if 
li_find = 0
if il_handle > 0 then 
	ll_handle = il_handle + 1
else
	ll_handle = tv_1.finditem(RootTreeItem! ,0)
end if 

//tv_1.expandall(ll_handle) 
tv_1.expandItem(ll_handle)  
do while ll_handle > 0 
	tv_1.getitem(ll_handle,ltvi_1)
//	if ltvi_1.label = ls_find then
	if pos(ltvi_1.label,ls_find) > 0  then //支持模糊查询
		li_find = 1
		exit
	end if
	ll_handle = tv_1.finditem(NextVisibleTreeItem! ,ll_handle) 
//	tv_1.expandall(ll_handle) 
	tv_1.expandItem(ll_handle) 
loop

ll_level = 1

if ll_handle > 0 then
	ll_handletree[ll_level] = ll_handle
	ll_handle = tv_1.finditem(ParentTreeItem! ,ll_handle)
	do while ll_handle > 0
		ll_level ++
		ll_handletree[ll_level] = ll_handle
		ll_handle = tv_1.finditem(ParentTreeItem! ,ll_handle)
	loop 
end if

ll_handle = tv_1.finditem(RootTreeItem! ,0)

do while ll_handle > 0
	tv_1.CollapseItem(ll_handle)
	ll_handle = tv_1.finditem(NextTreeItem! ,ll_handle)
loop

do while ll_level > 0 and li_find = 1
	tv_1.expanditem(ll_handletree[ll_level])
	if ll_level = 1 then
		tv_1.selectitem(ll_handletree[ll_level])
		tv_1.setfocus()
		il_handle = ll_handletree[ll_level] //记录上次查询的节点
		exit
	else 
		ll_level -- 
	end if 
loop

tv_1.setredraw(true)
if li_find = 0 then 
	il_handle = 0
	ll_handle = tv_1.finditem(RootTreeItem! ,0)
	tv_1.expandall(ll_handle) 
	Messagebox("提示","找不到【" + ls_find+"】!")	
end if 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:17093次
    • 积分:285
    • 等级:
    • 排名:千里之外
    • 原创:10篇
    • 转载:7篇
    • 译文:0篇
    • 评论:7条
    文章分类
    最新评论