大家好,我有一个非常简单的tree问题,希望你们能帮帮我!!!
在treeview中显示分层数据,数据表的内容是:
id name
01 西药
0101 抗微生物药
010101 影像诊断用药
010102 其他诊断用药
010103 清热泻火剂
010104 清脏腑热剂
0102 抗生素类抗感染药
010201 清热宣肺剂
010202 滋阴剂
010203 滋补肾阴
010204 滋补心肺
0103 氨基糖苷类
010301 温阳剂
010302 安神剂
02 中药
0201 四环素类
020101 疏肝解郁剂
020102 疏肝和胃剂
0202 酰胺醇类
020201 消导剂
020202 疏散外风
0203 大环内酯类
020301 散寒除湿通痹
020302 清热除湿通痹
我还是那个问题不明白:一个朋友给我写的代码,他在tv_1的itempopulate中写的部分代码
treeviewitem tvi2,tvi1
tvi2.pictureindex=1
tvi2.selectedpictureindex=3
this.getitem(handle,tvi1)
if tvi1.level=1 then
tvi2.data=ls_id
我都弄糊涂了,到底什么时候用tvi2,什么时候用tvi1?还有this.getitem(handle,tvi1)有什么作用??????????
整个itempopulate事件的代码如下:
string ls_name,ls_id
long i,ll_row
treeviewitem tvi2,tvi1
tvi2.pictureindex=1
tvi2.selectedpictureindex=3
datastore datatest
datatest=create datastore
datatest.dataobject='d_qw'
datatest.settransobject(sqlca)
this.getitem(handle,tvi1)
//messagebox("s",this.getitem(handle,tvi1))
if tvi1.level=1 then
ll_row=datatest.retrieve('00')
for i=1 to ll_row
ls_name=datatest.getitemstring(i,3)
ls_id=datatest.getitemstring(i,1)
tvi2.data=ls_id
tvi2.label=ls_name
tvi2.children=true
this.insertitemlast(handle,tvi2)
next
else
ll_row=datatest.retrieve(tvi1.data)
for i=1 to ll_row
tvi2.data=datatest.getitemstring(i,1)
tvi2.label=datatest.getitemstring(i,3)
tvi2.children=(tvi1.level<3)//假设最多有三层
this.insertitemlast(handle,tvi2)
next
end if
最后一个问题:上面的代码是假设有三层,但是实际肯定会有2层的时候,但它前面还有“+”,怎么才能去掉加号呢?