PB编写三层及三层树的函数

已经有很长时间没有来写作了,这段时间在用PB9去开发一个MIS系统,有用到构建三层树,就编写了一个函数wf_createmenutv
两个参数
dw datastore//传入datastore
al_handle long //树的Handle

函数内容

long ll_pos
long ll_insertlast_handle,ll_insertlast_handle_new
long ll_m
long ll_upperbound
long ll_macro

string ls_itemName
treeviewitem ltr_viewitem1
long parentid
long ID
datastore ids_Data,ids_data_child
ids_Data = Create DataStore
ids_Data.DataObject = “d_rule_macro”
ids_Data.SetTransObject(sqlca)
//子窗口
ids_data_child = Create DataStore
ids_data_child.DataObject = “d_rule_macro”
ids_data_child.SetTransObject(sqlca)

// dwMacro=dw_macro
ll_upperbound = dw.rowcount()
IF ll_upperbound = 0 THEN
RETURN
END IF
FOR ll_m = 1 TO ll_upperbound

ID =dw.object.ID[ll_m]
parentid =dw.object.parentID[ll_m]
ls_itemName = dw.object.itemName[ll_m]
if parentid=0 then
    ltr_viewitem1.pictureindex = 1
    ltr_viewitem1.selectedpictureindex = 2
    ltr_viewitem1.data=dw.object.ID[ll_m]
    ltr_viewitem1.label=ls_itemName
    ll_insertlast_handle = tv_1.insertitemlast(parentid,ltr_viewitem1)
else
    tv_1.getitem(al_handle,ltr_viewitem1)
    ll_insertlast_handle=al_handle
    //ll_insertlast_handle = tv_1.insertitemlast(parentid,ltr_viewitem1)
end if

//sub:
if ids_data.retrieve(ID)=0 then
//Destroy ids_data
//ll_insertlast_handle_old=al_handle
continue
end if
for ll_macro=1 to ids_data.rowcount()
// Tv_1.finditem(ParentTreeItem! ,ll_handle)
// Tv_1.GetItem( ll_insertlast_handle, ltr_viewitem1 )
ID = ids_data.object.ID[ll_macro]
ls_itemName = ids_data.object.itemName[ll_macro]
parentid=ids_data.object.parentID[ll_macro]
//ltr_viewitem1.children=true
//ltr_viewitem1.level = parentid
ltr_viewitem1.pictureindex = 1
ltr_viewitem1.selectedpictureindex = 2
ltr_viewitem1.data=ids_data.object.ID[ll_macro]
ltr_viewitem1.label=ls_itemName
//ltr_viewitem1.level=parentid
long ll_tvi
//ll_tvi = tv_1.FindItem(ParentTreeItem! , 0)
//ll_pos=ll_insertlast_handle
//ll_insertlast_handle_old=ll_insertlast_handle
// if ll_macro=1 then
// ll_insertlast_handle_new = tv_1.insertitemlast(ll_insertlast_handle,ltr_viewitem1)
//
// //wf_createmenutv(ids_data,ll_insertlast_handle_new)
ll_insertlast_handle_old=ll_insertlast_handle
// else

            ll_insertlast_handle_new = tv_1.insertitemlast(ll_insertlast_handle,ltr_viewitem1)
            //wf_createmenutv(ids_data,ll_insertlast_handle_new)

// end if
//_Parent=FindItem(ParentTreeItem!,handle)
if ids_data_child.retrieve(ID)=0 then
//Destroy ids_data_child
//ll_insertlast_handle_old=al_handle
continue
else
//ll_insertlast_handle=ll_insertlast_handle_new
//goto sub
wf_createSUBmenutv(ids_data_child,ll_insertlast_handle_new)
end if

next

NEXT
Destroy ids_data
Destroy ids_data_child
再编写类似的函数wf_createSUBmenutv,就可以达到三层以至无限层
long ll_pos
long ll_insertlast_handle,ll_insertlast_handle_new
long ll_m
long ll_upperbound
long ll_macro

string ls_itemName
treeviewitem ltr_viewitem1
long parentid
long ID
datastore ids_Data,ids_data_child
ids_Data = Create DataStore
ids_Data.DataObject = “d_rule_macro”
ids_Data.SetTransObject(sqlca)
//子窗口
ids_data_child = Create DataStore
ids_data_child.DataObject = “d_rule_macro”
ids_data_child.SetTransObject(sqlca)

// dwMacro=dw_macro
ll_upperbound = dw.rowcount()
IF ll_upperbound = 0 THEN
RETURN
END IF
FOR ll_m = 1 TO ll_upperbound

ID =dw.object.ID[ll_m]
parentid =dw.object.parentID[ll_m]
ls_itemName = dw.object.itemName[ll_m]

// if parentid=0 then
ltr_viewitem1.pictureindex = 1
ltr_viewitem1.selectedpictureindex = 2
ltr_viewitem1.data=dw.object.ID[ll_m]
ltr_viewitem1.label=ls_itemName
ll_insertlast_handle = tv_1.insertitemlast(al_handle,ltr_viewitem1)
// else
// tv_1.getitem(al_handle,ltr_viewitem1)
// ll_insertlast_handle=al_handle
// end if

if  ids_data.retrieve(ID)=0 then
            //Destroy ids_data
        //ll_insertlast_handle_old=al_handle
        continue
    end if
for ll_macro=1 to ids_data.rowcount()

// Tv_1.finditem(ParentTreeItem! ,ll_handle)
// Tv_1.GetItem( ll_insertlast_handle, ltr_viewitem1 )
ID = ids_data.object.ID[ll_macro]
ls_itemName = ids_data.object.itemName[ll_macro]
parentid=ids_data.object.parentID[ll_macro]
//ltr_viewitem1.children=true
//ltr_viewitem1.level = parentid
ltr_viewitem1.pictureindex = 1
ltr_viewitem1.selectedpictureindex = 2
ltr_viewitem1.data=ids_data.object.ID[ll_macro]
ltr_viewitem1.label=ls_itemName
//ltr_viewitem1.level=parentid
long ll_tvi
//ll_tvi = tv_1.FindItem(ParentTreeItem! , 0)
//ll_pos=ll_insertlast_handle
//ll_insertlast_handle_old=ll_insertlast_handle
// if ll_macro=1 then
// ll_insertlast_handle_new = tv_1.insertitemlast(ll_insertlast_handle,ltr_viewitem1)
//
// //wf_createmenutv(ids_data,ll_insertlast_handle_new)
ll_insertlast_handle_old=ll_insertlast_handle
// else
ll_insertlast_handle_new = tv_1.insertitemlast(ll_insertlast_handle,ltr_viewitem1)
//wf_createmenutv(ids_data,ll_insertlast_handle_new)
// end if
//_Parent=FindItem(ParentTreeItem!,handle)
if ids_data_child.retrieve(ID)=0 then
//Destroy ids_data_child
//ll_insertlast_handle_old=al_handle
continue
else
wf_createSUBmenutv(ids_data_child,ll_insertlast_handle_new)
end if
next

NEXT
Destroy ids_data
Destroy ids_data_child
没办法,只能又编写一个函数,才能满足子类中的子类

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值