Clicked()事件:
TreeViewItem ltvi_Item
String ls_Temp
Long ll_Handle
IF This.GetItem( Handle, ltvi_Item ) < 0 THEN Return
ls_Temp = ltvi_Item.Label //保存人员信息(李)
IF ltvi_Item.Level = 2 THEN
ll_Handle = This.FindItem( ParentTreeItem!, Handle )
IF This.GetItem( ll_Handle, ltvi_Item ) < 0 THEN Return //得到父级别TreeView信息. ltvi_Item.Data 就是班机
dw_1.Retrieve( ltvi_Item.Label, ls_Temp )
END IF
for i=1 to l_rowcount
if trim(data_area.getitemstring( i,"district"))="" then
tvi1.label=data_area.getitemstring(i,"prov_name")
l_tv=this.insertitemlast(l_lev0,tvi1)
name=data_area.getitemstring(i,"prov_name")
if name="北京市" or name="天津市" or name="上海市"or name="重庆市"then
for j=1 to l_rowcount
if data_area.getitemstring(j,"prov_name")=name and not trim(data_area.getitemstring(j,"district"))="" then
tvi2.label=data_area.getitemstring(j,"district")
this.insertitemlast(l_tv,tvi2)
end if
next
else
for j=1 to l_rowcount
if data_area.getitemstring(j,"prov_name")=name and not trim(data_area.getitemstring(j,"county"))="" then
tvi2.label=data_area.getitemstring(j,"county")
this.insertitemlast(l_tv,tvi2)
end if
next
end if
end if
next
ltvi_item.label="计算机3班"
ltvi_item.data="03"
tv_1.insertitemlast(0,ltvi_item)
然后在tv_1.itempopulate的事件中进行展开了
long ll_rowcount,ll_i,ll_handle,//当前接点的句柄
treeviewitem ltvi_item,ltvi_tree
this.getitem(ll_handle,ltvi_item)
ll_rowcount=ids_source.retrieve(string(ltvi_item.data))
if ll_rowcount>0 then
ltvi_tree.bold=false
ltvi_tree.children=false
ltvi_tree.selectedpictureindex="一个数字"
for ll_i=1 to ll_rowcount
ltvi_tree.label=ids_source.object.name[ll_i]
ltvi_tree.data=ids_source.object.emp_id[ll_i]
tv_1.insertitemsort(ll_handle,ltvi_tree)
next
end if
如果是简单的两层的treeview,就可以这样写了,如果要动态的加的话,就要通过游标来判断加入了。
Clicked()事件:
TreeViewItem ltvi_Item
String ls_Temp
Long ll_Handle
IF This.GetItem( Handle, ltvi_Item ) < 0 THEN Return
ls_Temp = ltvi_Item.Data //保存人员信息(李)
IF ltvi_Item.Level = 2 THEN
ll_Handle = This.FindItem( ParentTreeItem!, Handle )
IF This.GetItem( ll_Handle, ltvi_Item ) < 0 THEN Return //得到父级别TreeView信息. ltvi_Item.Data 就是班机
dw_1.Retrieve( ltvi_Item.Data, ls_Temp )
END IF