long il_LastSelectedRow = 1
然後開始編寫多行選中程序。程序算法描述如下:
1、如果按下了Control鍵
如果是在選中行上,取消該行
否則,選中該行
記錄當前到窗口實例變量中
2、如果按下了Shift鍵
取消所有選中行
選中上次點擊行和當前行之間的所有數據行
記錄當前到窗口實例變量中
3、如果沒有按鍵
如果點擊行爲選中行,不執行任何操作
否則,取消所有選中行,選中當前行
記錄當前到窗口實例變量中
比如,我們在窗口dw_1的Clicked事件中編寫該腳本,程序如下:
long ll_Start
long ll_End
long ll_index
if Row < 1 then return
if KeyDown(KeyControl!) then
if This.IsSelected(Row) then
This.SelectRow(Row,False)
else
This.SelectRow(Row,True)
end if
elseif KeyDown(KeyShift!) then
if Row < il_LastSelectedRow then
ll_Start = Row
ll_End = il_LastSelectedRow
else
ll_Start = il_LastSelectedRow
ll_End = Row
end if
This.SelectRow(0,False)
For ll_index = ll_Start to ll_End
This.SelectRow(ll_index,True)
next
else
if Not This.IsSelected(Row) then
This.SelectRow(0,False)
This.SelectRow(Row,True)
end if
end if
il_LastSelectedRow = Row