以下是引用吹水佬在2015-2-3 20:09:03的发言:
动态编程,还是觉得自己封装一个GRID类好用点,用AddObject和RemoveObject方法就可以。
动态编程,还是觉得自己封装一个GRID类好用点,用AddObject和RemoveObject方法就可以。
老师能给个例子,好好学习封装一个GRID类及AddObject和RemoveObject方法,顺便解决自己的难题。谢谢。
CREATE CURSOR db (f1 I, f2 I) INSERT INTO db VALUES (111, 122) GO TOP of = NEWOBJECT("_form") of.Show READ EVENTS RETURN DEFINE CLASS _form As Form ADD OBJECT Pageframe1 AS _Pageframe PROCEDURE UnLoad CLEAR EVENTS ENDPROC ENDDEFINE DEFINE CLASS _Pageframe AS Pageframe PageCount = 2 Visible = .T. PROCEDURE Page1.Init this.Caption = "点击第2页看看" ENDPROC PROCEDURE Page2.Activate IF VARTYPE(this.Grid1) == "O" this.RemoveObject("Grid1") ENDIF this.AddObject("Grid1", "_Grid") this.Grid1.SetFocus ENDPROC ENDDEFINE DEFINE CLASS _Grid AS Grid Visible = .T. PROCEDURE Init this.RecordSource = "db" this.ColumnCount = 2 this.Column1.ControlSource = "db.f1" this.Column2.ControlSource = "db.f2" this.Column1.RemoveObject("Text1") this.Column1.AddObject("Text1", "_Text") ENDPROC ENDDEFINE DEFINE CLASS _Text AS TextBox Visible = .T. PROCEDURE InteractiveChange thisform.Caption = TRANSFORM(this.Value) ENDPROC ENDDEFINE