PB TreeView 控制元件實現查詢功能
阿新 • • 發佈:2019-01-22
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