程序代码:
PUBLIC oForm
oForm = NEWOBJECT("Form1")
oForm.Show
RETURN
DEFINE CLASS form1 AS form
DoCreate = .T.
AutoCenter = .T.
Caption = "Form1"
Name = "Form1"
ADD OBJECT grid1 AS grid WITH ;
FontName = "YaHei Consolas Hybrid", ;
FontSize = 11, ;
Height = 200, ;
Left = 12, ;
RowHeight = 23, ;
Top = 24, ;
Width = 320, ;
Name = "Grid1"
PROCEDURE Init
Create Cursor T (A1 N(4),A2 N(4),A3 N(4))
Insert Into T Values (10,100,1000)
Insert Into T Values (1000,10,100)
Insert Into T Values (100,1000,10)
Go Top
With ThisForm.Grid1
.ColumnCount=Fcount("T")
.RecordSource="T"
.RecordSourceType=0
For lnI=1 To .ColumnCount
myField=Field(lnI)
.Columns(lnI).DynamicForeColor="Icase(&myField=10,Rgb(255,0,0),&myField=100,Rgb(0,255,0),Rgb(0,0,255))"
.Columns(lnI).Header1.Caption=Field(lnI)
EndFor
.Refresh
EndWith
ENDPROC
PROCEDURE grid1.AfterRowColChange
LPARAMETERS nColIndex
thisform.Caption=TRANSFORM(thisform.Grid1.Columns[nColIndex].Text1.Value)
ENDPROC
ENDDEFINE