treeview控件选择了checkboxes属性,每个item前面有个checkbox,想通过程序来选中checkbox,该怎么做呢?
ltvi_1.selected=isSelected
tv_2.SetItem( ll_handle, ltvi_1 )
这样不行,只是item项目被光标选中了,checkbox没有checked,..........
------解决方案--------------------
tv_1 的 clicked 事件:
treeviewitem tvitem,tvitem_next
getitem(handle, tvitem)
post event ue_check_changed(handle, tvitem.statepictureindex)
增加事件 ue_check_changed(long handle, integer prevstate)
treeviewitem tvitem
getitem(handle, tvitem)
if tvitem.statepictureindex=prevstate then
return
else
this.Event ue_check_children(handle, tvitem.statepictureindex)
if tvitem.statepictureindex=1 then
this.Event ue_check_parent(handle, tvitem.statepictureindex)
end if
end if
增加事件 ue_check_children(long handle , integer state)
long childitem
treeviewitem tvitem
getitem(handle, tvitem)
tvitem.statepictureindex=state
setitem(handle, tvitem)
childitem=this.finditem(ChildTreeItem!, handle)
do while(childitem <>-1)
this.Event ue_check_children(childitem, state) //递归遍历后代结点
childitem=this.finditem(NextTreeItem!, childitem)
loop
增加事件 ue_check_parent(long handle , integer state)
long parentitem
treeviewitem tvitem
getitem(handle, tvitem)
tvitem.statepictureindex=state
setitem(handle, tvitem)
parentitem=this.finditem(ParentTreeItem!, handle)
if parentitem <>-1 then
this.Event ue_check_parent(parentitem, state)
end if
自己注意事件的添加顺序