没具体数据
只给个简单示例参考
CREATE CURSOR tt (f1 C(10),f2 I,f3 I)
INSERT INTO tt VALUES ("一", 1, 12)
INSERT INTO tt VALUES ("二", 2, 22)
INSERT INTO tt VALUES ("三", 3, 32)
GO TOP
of = CREATEOBJECT("form1")
of.show(1)
RETURN
DEFINE CLASS form1 AS form
Height = 300
ADD OBJECT label1 AS label WITH AutoSize=.T.,BackStyle=0,Caption="f1",Left=31,Top=26
ADD OBJECT label2 AS label WITH AutoSize=.T.,BackStyle=0,Caption="f2",Left=31,Top=50
ADD OBJECT label3 AS label WITH AutoSize=.T.,BackStyle=0,Caption="f3",Left=31,Top=74
ADD OBJECT text1 AS textbox WITH Height=20,Left=48,Top=24
ADD OBJECT text2 AS textbox WITH Height=20,Left=48,Top=48
ADD OBJECT text3 AS textbox WITH Height=20,Left=48,Top=72
ADD OBJECT cmd1 AS commandbutton WITH Top=24,Left=180,Height=25,Caption="添加"
ADD OBJECT cmd2 AS commandbutton WITH Top=60,Left=180,Height=25,Caption="修改"
ADD OBJECT grid1 AS grid WITH Left=10,Top=100
PROCEDURE Init
this.grid1.AfterRowColChange
ENDPROC
PROCEDURE cmd1.Click
IF !EMPTY(thisform.text1.Value)
INSERT INTO tt VALUES (thisform.text1.Value,thisform.text2.Value,thisform.text3.Value)
thisform.grid1.SetFocus
ENDIF
ENDPROC
PROCEDURE cmd2.Click
IF !EMPTY(thisform.text1.Value)
REPLACE tt.f1 WITH thisform.text1.Value,;
tt.f2 WITH thisform.text2.Value,;
tt.f3 WITH thisform.text3.Value
thisform.grid1.SetFocus
ENDIF
ENDPROC
PROCEDURE grid1.AfterRowColChange
LPARAMETERS nColIndex
IF this.RowColChange != 2
thisform.text1.Value = tt.f1
thisform.text2.Value = tt.f2
thisform.text3.Value = tt.f3
ENDIF
ENDPROC
ENDDEFINE