设置一个计数器,避开首次双击时第二次触发的RowColChange事件,基本可用吧,没仔细测试各种情况
程序代码:
Create Cursor tt (F1 C(10), F2 C(10), F3 I)
Insert Into tt Values ("ABC", "123456", 101)
Clear
Insert Into tt Values ("DEF", "654321", 202)
Insert Into tt Values ("GHI", "456123", 303)
Go Top
Of = Createobject("form1")
Of.Show(1)
Define Class form1 As Form
AllowOutput = .F.
AutoCenter = .T.
Add Object grid1 As myGrid
Enddefine
Define Class myGrid As Grid
AllowCellSelection = .F.
RowHeight = 22
DblTimes = 0 && 用于判断是否首次双击
Procedure DblClick
*!* ? Textmerge('第 <<This.DblTimes>> 次双击')
Local nWhere, oo
Local aTemp[1]
*!* nWhere = 0
*!* This.GridHitTest(Mcol(0,3),Mrow(0,3), @ nWhere)
*!* If nWhere != 3
*!* Return
*!* EndIf
= AMouseObj(aTemp)
oo = aTemp[1]
If (Vartype(oo) == 'O') and (Lower(oo.BaseClass) $ ',textbox,combobox,checkbox,XXXX,')
This.AllowCellSelection = .T.
This.ReadOnly = .F.
oo.SetFocus()
Else
This.AllowCellSelection = .F.
EndIf
Endproc
Procedure AfterRowColChange(nColIndex)
*!* ? 'After Event'
If This.DblTimes > 1
This.AllowCellSelection = .F.
EndIf
This.DblTimes = This.DblTimes + 1
Endproc
EndDefine
[此贴子已经被作者于2022-9-8 13:18编辑过]