回复 19楼 laowan001
没错,换成这个就简单多了,谢谢指导。
[此贴子已经被作者于2022-12-7 13:53编辑过]
PROCEDURE AfterRowColChange(nColIndex) IF this.RowColChange == 1 this.index = RECNO() this.SetFocus ENDIF ENDPROC PROCEDURE BackStyle_ACCESS this.Picture = IIF(RECNO("tt")==thisform.grd.index,"d:\temp\test_0.ico","d:\temp\test_1.ico") RETURN THIS.BackStyle ENDPROC
CREATE CURSOR tt (img v(1), f1 v(10)) FOR i=1 TO 9 INSERT INTO tt VALUES ("", REPLICATE(TRANSFORM(i),10)) ENDFOR GO TOP of = CREATEOBJECT("form1") of.show(1) RETURN DEFINE CLASS form1 as Form AllowOutput = .f. AutoCenter = .t. ADD OBJECT cmd as commandbutton WITH left=10,top=10,height=24,caption="Enabled=.F." ADD OBJECT grd as grid1 PROCEDURE cmd.click this.Caption = "Enabled="+TRANSFORM(thisform.grd.Enabled) thisform.grd.Enabled = !thisform.grd.Enabled ENDPROC ENDDEFINE DEFINE CLASS grid1 as Grid left=10 top=40 width=200 RowHeight=32 HeaderHeight=0 GridLines=0 DeleteMark=.f. RecordMark=.f. AllowCellSelection=.f. SplitBar=.f. ScrollBars=2 index = 1 PROCEDURE init this.Column1.width=32 this.Column1.RemoveObject("Text1") this.Column1.AddObject("img", "grdimg") this.Column1.Sparse = .F. ENDPROC PROCEDURE AfterRowColChange(nColIndex) IF this.RowColChange == 1 this.index = RECNO() this.SetFocus ENDIF ENDPROC ENDDEFINE DEFINE CLASS grdimg AS image BackStyle = 0 Width = 32 Height = 32 Stretch = 0 PROCEDURE BackStyle_ACCESS this.Picture = IIF(RECNO("tt")==thisform.grd.index,"d:\temp\test_0.ico","d:\temp\test_1.ico") RETURN THIS.BackStyle ENDPROC ENDDEFINE