Username: Password:

操作treeview 控件的两个函数(转贴+原创)-数据库专栏,SQL Server
来源:作者: 发布时间:2007-12-25 13:48:57


/**********************************************************/
//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 ) //递归函数

喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅