GRID 修改即显示的问题
本帖最后由 asonglinux 于 2012-11-27 14:04:03 编辑
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'
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