操作treeview 控件的两个函数(转贴+原创)

类别:数据库 点击:0 评论:0 推荐:

/**********************************************************/
//function        : 遍历所有的项,查找目标项
//uf_find_item
//para            :
//      1. handle : 项目句柄     long
//      2. a_data : 目标项数据 string
//      3. ai_type: 查找类型 int
//return          : (none)
//
//date        
//comment         :
//      ai_type = 1 是准确查找
//      ai_type = 2 是模糊查找
/*********************************************************/

Long l_ret,l_find
TreeViewItem ltvi_find

//没有找到
ib_find = FALSE

IF IsNull(a_data) THEN
// MessageBox(ga_app.dwmessagetitle,"请输入查询条件 !",StopSign!)
 RETURN -1
END IF

//Do While Yield()
//Loop

DO WHILE handle <> -1 AND NOT ib_find
 THIS.GetItem(handle,ltvi_find)
 IF ai_type = 1 THEN //是准确查找
  IF string(ltvi_find.data) = a_data THEN
   SelectItem(handle)
   ib_find = TRUE
   RETURN handle
  END IF
 ELSE  //是模糊查找
  IF Pos(ltvi_find.label,String(a_data)) > 0 THEN
   SelectItem(handle)
   IF MessageBox('','是否查找下一项 "' +&
    String(a_data) + ' "' ,Question!,YesNo!,2) = 2 THEN
    ib_find = TRUE
    RETURN handle
   END IF
  END IF
 END IF
  //---判断该项是否有子项,有则,递归调用,处理返回值取得目标项句柄---//
 l_ret = THIS.FindItem(ChildTreeItem!,handle)
 IF l_ret >0 THEN
  l_find = THIS.uf_find_item(l_ret,a_data,ai_type)
 END IF
 handle = THIS.FindItem(NextTreeItem!,handle)
LOOP

IF ib_find THEN
 RETURN l_find
ELSE
 RETURN -1
END IF


//=====================================
////ue_deleteitems
//删除所有树形节点的函数
//long al_handle
//wuhai
//20040725
//======================================
long ll_chi_handle,ll_parent_handle
long ll_c
ll_chi_handle = this.FindItem (ChildTreeItem! , al_handle )
if ll_chi_handle > 0 then 
 this.event ue_deleteitems(ll_chi_handle ) //递归函数

end if
ll_parent_handle = this.FindItem (ParentTreeItem!  , al_handle)
if al_handle =-1 and ll_parent_handle = -1 and ll_chi_handle= -1 then return
this.deleteitem(al_handle)
il_c ++
this.event ue_deleteitems(ll_parent_handle ) //递归函数

本文地址:http://com.8s8s.com/it/it20433.htm