急!!!treeview中如果出现点加号有重复条目,怎样可以控制不出现在哪个事件里加条件?是在of_set_item里吗?

wj936 2003-09-29 01:44:28
希望大家指教
...全文
41 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenzhenyi 2003-10-04
  • 打赏
  • 举报
回复
在itempopulate里面,关键在于如何形成过滤条件,例如在open中是如下代码:
ds_1=create datastore
ds_1.dataobject="d_win_tree"
ds_1.settransobject(SQLCA)
ds_1.retrieve()
//数据过滤
ds_1.SetFilter("right(id,9)='000000000'")
ds_1.Filter()
//messagebox("number:",string(ds_1.rowcount()))
//设置树当前层属性
item.pictureindex=1
item.selectedpictureindex=1
//保存当前层id和name值
integer k,rct
rct=ds_1.RowCount()
//messagebox("",string(rct))
for k=1 to rct
id_name[k,1]=ds_1.getitemstring(k,"name")
id_name[k,2]=ds_1.getitemstring(k,"id")
// id_name[k,3]=ds_1.getitemstring(k,"window")
next
//插入树根项
string ss
for k=1 to rct
item.label=id_name[k,1]
item.data =id_name[k,2]
ss="left(id,1)='"+left(item.data,1)+"'"
ds_1.SetFilter(ss)
ds_1.Filter()
item.children = ds_1.RowCount()>1
tv_1.insertitemlast(0,item)
next
//messagebox("","success!!!")
则在itempopulate事件中写如下代码过滤:
//取得当前项
getitem(handle,item)
//根据层次和编码形成过滤条件
string ss
IF item.level=1 THEN
// ss="right(id,9)='000000000' and right(id,6)<>'000000' and left(id,1)='"+left(item.data,1)+"'"
ss="right(id,6)='000000' and right(id,9)<>'000000000' and left(id,1)='"+left(item.data,1)+"'"
ELSEIF item.level=2 THEN
// ss="right(id,6)='000000' and right(id,9)<>'000000000' and left(id,4)='"+left(item.data,4)+"'"
ss="right(id,4)='0000' and right(id,6)<>'000000' and left(id,4)='"+left(item.data,4)+"'"

ELSEIF item.level=3 THEN
// ss="right(id,4)='0000' and right(id,6)<>'000000' and left(id,6)='"+left(item.data,6)+"'"
ss="right(id,4)<>'0000' and left(id,6)='"+left(item.data,6)+"'"
//elseif item.level=4 then
// ss="right(id,4)<>'0000' and left(id,6)='"+left(item.data,6)+"'"

END IF
//数据过滤

ds_1.SetFilter(ss)
ds_1.Filter()
//设置树下一层属性
item.pictureindex=item.level+1
item.selectedpictureindex=item.level+1
//保存下一层id和name值
integer k,rct
rct=ds_1.RowCount()
//messagebox("",string(ds_1.rowcount()))
for k=1 to rct
id_name[k,1]=ds_1.getitemstring(k,"name")
id_name[k,2]=ds_1.getitemstring(k,"id")
next
//插入树项
for k=1 to rct
item.label=id_name[k,1]
item.data =id_name[k,2]

choose case item.level
case 1
ss="left(id,4)='"+left(item.data,4)+"'"
case 2
ss="left(id,6)='"+left(item.data,6)+"'"
case 3
ss="left(id,10)='"+left(item.data,10)+"'"
// case 4
// ss="left(id,10)='"+left(item.data,10)+"'"
END choose
ds_1.SetFilter(ss)
ds_1.Filter()
item.children = ds_1.RowCount()>1
this.insertitemlast(handle,item)
next
wj936 2003-10-04
  • 打赏
  • 举报
回复
不好意思,那天着急,没写清楚。
treeview中如果出现点加号有重复条目,怎样可以控制不出现?在哪个事件里加条件?是在of_set_
生成树中的条目是从两个查询中合并出来的,有重复项,怎样去掉?
xh308 2003-09-29
  • 打赏
  • 举报
回复
把你在constructor事件中写的代码移至getfocus事件中
workhand 2003-09-29
  • 打赏
  • 举报
回复
如果生成树的时候不插入重复结点,就不会有了
workhand 2003-09-29
  • 打赏
  • 举报
回复
应该是这样:怎样可以控制不出现(此种情况),(需要)在哪个事件里加条件?
问楼主是否是这个意思,呵呵
peter_zy 2003-09-29
  • 打赏
  • 举报
回复
费思量,楼主是不是想删除重复的条目呢?请说的详细点!
jdsnhan 2003-09-29
  • 打赏
  • 举报
回复
我也没看明白,请楼主再详细的说说什么意思。
intuition444 2003-09-29
  • 打赏
  • 举报
回复
怎样可以控制不出现在哪个事件里加条件?

没看明白!

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧