先上一图看看效果
在PB的Datawindow中不似list等控件,默认不支持多选(CTRL、SHIFT)但可以通过代码来实现。下边就列出多选的实现方法。
补充说明:其它与其它开发工具中的选择行相比较而言,PB的Datawindow中的行默认情况下鼠标点选后,该行并没有选中,而是需要一个Boolean的变量标记行是否选中。
首先要在变量声明中定义如下变量:
代码放在这里,方便大家复制(呵呵)
- boolean ib_multiSelect = True
- long il_lastRow=0
- long il_firstRow=0
- int ii_current_style = 0
然后在函数体中加入如下实现代码:
- long lCr
- int iStep
- string ls_CurObj, ls_CurCol
- integer li_LinePos
- if isnull(dw.dataobject) or len(string(dw.dataobject)) <= 0 then return
- if row <> 0 then
- if (ib_multiSelect = True) then
- if KeyDown( KeyControl! ) then
- if dw.isSelected( Row ) = True then
- dw.SelectRow( Row,False )
- else
- dw.SelectRow( Row,True )
- dw.SetRow( Row )
- end if
- il_FirstRow = Row
- else
- if KeyDown( KeyShift! ) then
- dw.SelectRow( 0,False )
- if Row > il_FirstRow then
- for lCr = il_FirstRow to Row
- if lCr>0 and lCr<=dw.Rowcount() then
- dw.SelectRow( lCr,True )
- end if
- next
- else
- for lCr = il_FirstRow to Row Step -1
- if lCr>0 and lCr<=dw.Rowcount() then
- dw.SelectRow( lCr,True )
- end if
- next
- end if
- else
- dw.SelectRow( 0,False )
- dw.SelectRow( Row,True )
- dw.SetRow( Row )
- il_FirstRow = Row
- end if
- end if
- else
- dw.SelectRow( 0,False )
- if ii_current_style = 0 then
- dw.SelectRow( Row,True )
- end if
- dw.SetRow( Row )
- il_FirstRow = Row
- end if
- end if
最后在Datawindow的Clicked中调用此方法即可:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
原来搜索了一个类似的方法,但有些问题,感谢秦哥提供了方法,在那之上调整了通用的Datawindow