740
社区成员
发帖
与我相关
我的任务
分享
public subroutine
wf_create_tree (integer al_userid, integer al_handle);//================================
//===功能:刷新树 ===
//===参数:al_userid 用户ID ===
//=== al_handle 节点句柄 ===
//================================
long i, ll_count //DS的记录行数
long ll_functionid //功能ID
long ll_handle_new //新节点句柄
long ll_picture_count //树形控件的图片总量
string ls_img //节点图片
long ll_temp
datastore ds_tree //数据源
treeviewitem ltvi_new ,ltvi_item //新节点,当前节点
//删除图片
ll_picture_count = upperbound(tv_rights.picturename[])
for i=1 to ll_picture_count
tv_rights.deletepicture( i )
next
ds_tree = create datastore
ds_tree.dataobject = 'd_set_userright_tree'
ds_tree.settransobject(sqlca)
//通过句柄获取当前节点data值(功能ID)
if al_handle > 0 then
tv_rights.getitem(al_handle, ltvi_item)
ll_functionid = long(ltvi_item.data)
else
ll_functionid = 0
end if
//刷新DS
ll_count = ds_tree.retrieve(al_userid,ll_functionid)
//循环,插入子节点
for i=1 to ll_count
ltvi_new.label = ds_tree.getitemstring(i,'name')
ltvi_new.data = ds_tree.getitemnumber(i,'id')
ls_img = ds_tree.getitemstring(i,'img')
if (isnull(ls_img) or trim(ls_img) = '') = false then
ll_temp = tv_rights.addpicture( ls_img)
ltvi_new.pictureindex = ll_temp
ltvi_new.selectedpictureindex = ll_temp
else
ltvi_new.pictureindex = 0
ltvi_new.selectedpictureindex = 0
end if
if ds_tree.getitemstring(i,'right') = 'Y' then
ltvi_new.statepictureindex = 2
else
ltvi_new.statepictureindex = 1
end if
ll_handle_new = tv_rights.insertitemlast( al_handle,ltvi_new )
wf_create_tree(al_userid,ll_handle_new)
next
//如果存在子节点,则更新当前节点
if al_handle > 0 and ll_count > 0 then
if ltvi_item.children = false then
ltvi_item.children = true
tv_rights.setitem(al_handle,ltvi_item)
end if
end if
destroy ds_tree
end subroutine
数的编辑,右键新增,删除,修改,这个也不难
在 tree_view 的 rightclicked 事件里书写
弹出菜单的代码
根据得到的句柄 handle 进行处理