creat cursor TABLEA(地名 C(10))
INSERT INTO TABLEA VALUES("北京")
INSERT INTO TABLEA VALUES("上海")
INSERT INTO TABLEA VALUES("天津")
THISFORM.GRID1.RECORDSOURCE='TABLEA'
creat cursor TABLEB(城市 C(10))
INSERT INTO TABLEB VALUES("北京")
INSERT INTO TABLEB VALUES("上海")
INSERT INTO TABLEB VALUES("天津")
INSERT INTO TABLEB VALUES("北京")
INSERT INTO TABLEB VALUES("上海")
INSERT INTO TABLEB VALUES("天津")
INSERT INTO TABLEB VALUES("北京")
INSERT INTO TABLEB VALUES("上海")
INSERT INTO TABLEB VALUES("天津")
THISFORM.GRID2.RECORDSOURCE='TABLEB'
现在的问题是。我要在GRID1 里面 修改 ‘北京’ 为 ’首都北京‘
要实现的结果是在GRID2 里自动修改显示 ‘北京’ 为 ’首都北京‘
------解决方案--------------------------------------------------------
grid1.AfterRowColChange 事件
grid1.BeforeRowColChange 事件
为你要的代码
Public oform1
oform1=Newobject("form1")
oform1.Show
Return
Define Class form1 As Form
Top = -1
Left = -1
DoCreate = .T.
Caption = "Form1"
Name = "form1"
Add Object grid1 As Grid With ;
DeleteMark = .F., ;
Height = 240, ;
Left = 9, ;
Top = 5, ;
Width = 120, ;
Name = "Grid1"
Add Object grid2 As Grid With ;
DeleteMark = .F., ;
Height = 240, ;
Left = 141, ;
Top = 5, ;
Width = 228, ;
Name = "Grid2"
Procedure Init
Creat Cursor TABLEA (地名 C(10))
Insert Into TABLEA Values("北京")
Insert Into TABLEA Values("上海")
Insert Into TABLEA Values("天津")
Locate
Thisform.GRID1.RecordSource='TABLEA'
Creat Cursor TABLEB (城市 C(10))
Insert Into TABLEB Values("北京")
Insert Into TABLEB Values("上海")
Insert Into TABLEB Values("天津")
Insert Into TABLEB Values("北京")
Insert Into TABLEB Values("上海")
Insert Into TABLEB Values("天津")
Insert Into TABLEB Values("北京")
Insert Into TABLEB Values("上海")
Insert Into TABLEB Values("天津")
Locate
Thisform.GRID2.RecordSource='TABLEB'
Endproc
Procedure grid1.AfterRowColChange
Lparameters nColIndex
Select TABLEA
This.Tag=Alltrim(地名)
Endproc
Procedure grid1.BeforeRowColChange
Lparameters nColIndex
lcTextVal=Alltrim(This.Columns(nColIndex).Text1.Value)
If Not Alltrim(This.Tag)==lcTextVal
Update TABLEB Set 城市=lcTextVal Where Alltrim(城市)==Alltrim(This.Tag)
Thisform.Grid2.Refresh
Endif
Endproc
Enddefine