表格的某些操作确实难倒了很多狐友,参考吹版和csyx版的发帖,我做了一下改进,看是否能达到楼主的满意:
程序代码:
CREATE CURSOR tt (F1 C(10), F2 C(10), F3 I) INSERT INTO tt VALUES ("ABC", "123456", 101) INSERT INTO tt VALUES ("DEF", "654321", 202) INSERT INTO tt VALUES ("GHI", "456123", 303) GO TOP of = CREATEOBJECT("form1") of.show(1) RETURN DEFINE CLASS form1 as Form ADD OBJECT grid1 as myGrid ADD OBJECT text1 as textbox WITH top = 210 && 增加了一个文本框控件,是为了验证活动控件为文本框时,双击表格行是否能切换到单元格 ENDDEFINE DEFINE CLASS myGrid as Grid AllowCellSelection = .f. DblTimes = 0 && 用于判断是否首次双击 PROCEDURE DblClick LOCAL oo as TextBox,aTemp[1] AMOUSEOBJ(aTemp) oo = aTemp[1] IF VARTYPE(oo) = 'O' AND oo.BaseClass = 'Textbox' THIS.AllowCellSelection = .t. THIS.ReadOnly = .f. oo.Parent.SelectOnEntry = .f. && 首次双击时不选择单元格,保持与再次双击时效果一致 oo.SetFocus ENDIF ENDPROC PROCEDURE AfterRowColChange(nColIndex) IF THIS.DblTimes != 0 THIS.AllowCellSelection = .f. ENDIF THIS.DblTimes = 1 ENDPROC PROCEDURE When THIS.DblTimes = 0 && 表格获得焦点时,初始化双击标识 ENDPROC ENDDEFINE
泉城飞狐