treeview使用checkedbox属性

yuhx 2002-03-23 09:42:12
treeview使用checkedbox属性后,如何在增加item的时候,加上选定标志,语句该如何写?
...全文
73 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Leehunter 2002-03-23
  • 打赏
  • 举报
回复
简而言之,设置treeviewitem的
statepictureindex=1为未选状态,=2为选中状态。
同样,获取是否选中也是使用该属性。
flymeng 2002-03-23
  • 打赏
  • 举报
回复
你先做两个图片,一个是不选中的框,一个是选 中的框里有对号的,然后把它加入到treeview的states,然后就在treeview的constructor 里写入



TreeViewItem ltvi_root

Integer li_index
Integer li_items = 5

Long ll_lev0

String ls_list,menu_name
String ls_root = 'Check box例子'

ltvi_root.Label ="设置"
ll_lev0 = this.InsertItemLast(0, ltvi_root)
ltvi_root.PictureIndex = 2
ltvi_root.SelectedPictureIndex = 2
ltvi_root.StatePictureIndex = 1
//----------------------
你要做的处理程序
//------------------------

在treeview的clicked事件里输入



Long ll_rc


If ib_stateclick Then
ll_rc = this.Of_SelectItem(handle, NOT this.Of_IsSelected(handle))
End If

Return ll_rc



其中Of_SelectItem是这样写的:
TreeViewItem ltvi_node

Integer li_rc

Long ll_handle


If al_handle > 0 Then
this.GetItem(al_handle, ltvi_node)
If ab_switch Then
Choose Case ltvi_node.StatePictureIndex
Case 1
ltvi_node.StatePictureIndex = 2 // Check Box
this.SetItem(al_handle, ltvi_node)
li_rc = 1
Case 3
ltvi_node.StatePictureIndex = 4 // Check Radio
this.SetItem(al_handle, ltvi_node)

// Uncheck all sibling radio buttons.
ll_handle = al_handle
Do While ll_handle <> -1
ll_handle = this.FindItem(PreviousTreeItem!, ll_handle)
If ll_handle > 0 Then
this.GetItem(ll_handle, ltvi_node)
If ltvi_node.StatePictureIndex = 4 Then
ltvi_node.StatePictureIndex = 3
this.SetItem(ll_handle, ltvi_node)
End If
End If
Loop
ll_handle = al_handle
Do While ll_handle <> -1
ll_handle = this.FindItem(NextTreeItem!, ll_handle)
If ll_handle > 0 Then
this.GetItem(ll_handle, ltvi_node)
If ltvi_node.StatePictureIndex = 4 Then
ltvi_node.StatePictureIndex = 3
this.SetItem(ll_handle, ltvi_node)
End If
End If
Loop
li_rc = 1
End Choose
Else
Choose Case ltvi_node.StatePictureIndex
Case 2
ltvi_node.StatePictureIndex = 1 // Uncheck Box
this.SetItem(al_handle, ltvi_node)
li_rc = 1

Case 4
// Cannot uncheck radio -- Only through checking another item.
li_rc = 0
End CHoose
End If
End If

Return li_rc




然后再用一个of_isSelected来处理被选中的项:
TreeViewItem ltvi_node

Long ll_rc


ll_rc = this.GetItem(al_handle, ltvi_node)

If ll_rc > 0 Then
Return ltvi_node.StatePictureIndex = 2 OR ltvi_node.StatePictureIndex = 4
End If

Return False









am2000 2002-03-23
  • 打赏
  • 举报
回复
up

400

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 非技术版
社区管理员
  • 非技术版社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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