*dynamicBackcolor applied to grid colums
*The speed is normal for VFP9 and dont slow visibilly. VFP8 might have the same behavior.
*added a timer to draw dynamically the grid with some dynamicColor property (random color)
*i reload the recordsource also each time (4-5 times).
Publi oform
oform=Newobject("asup")
oform.Show
Read Events
Retu
*
Define Class asup As Form
Top = 0
Left = 0
Height = 429
Width = 880
AutoCenter=.T.
ShowWindow=2
ycount=0
Name = "Form1"
Add Object grid1 As Grid With ;
Anchor = 15, ;
Height = 433, ;
Left = 1, ;
Top = 0, ;
Width = 877, ;
Name = "Grid1"
Add Object timer1 As Timer With ;
interval=5000,;
name="timer1"
Procedure Destroy
Use In Select("ycurs")
Dele File ycurs.Dbf
Clea Events
Endproc
Procedure timer1.Timer
Rand(-1)
Sele ycurs
With Thisform
.ycount=.ycount+1
If .ycount>4
This.Enabled=.F.
Endi
Wait Window Trans(.ycount) Nowait
Endwith
With Thisform.grid1
.RecordSource=""
.Refresh
.RecordSource="ycurs"
.RecordSourceType=1
.DeleteMark=.F.
.GridLines=0
.AutoFit()
Local m.x
m.x=Trans(Rgb(255*Rand(),255*Rand(),255*Rand()))
.SetAll("DynamicBackColor", "IIF(MOD(RECNO( ), 2)=0, RGB(212,210,208) , "+m.x+")","column")
.Column3.DynamicBackColor = "rgb(255,164,164)"
.column5.DynamicBackColor ="rgb(255,255,0)"
.Column3.FontBold=.T.
.Column3.ForeColor=Rgb(128,0,64)
Locate
.Parent.Caption=Trans(Reccount())+ " records loaded"
.Refresh
Endwith
Endproc
Procedure grid1.Init
_Screen.WindowState=1
Close Data All
Sele * From Home(1)+"samples\data\customer" Into Table ycurs1
Sele * From Home(1)+"samples\data\customer" Into Table ycurs2
Sele * From Home(1)+"samples\data\customer" Into Table ycurs3
Sele * From Home(1)+"samples\data\customer" Into Table ycurs4
Sele * From Home(1)+"samples\data\customer" Into Table ycurs5
Sele * From Home(1)+"samples\data\customer" Into Table ycurs6
*create a new table
Sele ycurs1
Copy Stru To ycurs.Dbf
Use ycurs Alias ycurs
Sele ycurs
Appe From "ycurs1.dbf"
Appe From "ycurs2.dbf"
Appe From "ycurs3.dbf"
Appe From "ycurs4.dbf"
Appe From "ycurs5.dbf"
Appe From "ycurs6.dbf"
Close Data All
*clean
For i=1 To 6
Dele File ("ycurs"+Trans(i)+".dbf")
Endfor
*populate the grid
Use ycurs Alias ycurs
Sele ycurs
With This
.RecordSource="ycurs"
.RecordSourceType=1
.DeleteMark=.F.
.GridLines=0
.AutoFit()
.SetAll("DynamicBackColor", "IIF(MOD(RECNO( ), 2)=0, RGB(212,210,208) , RGB(0,255,0))","column")
.Column3.DynamicBackColor = "rgb(255,164,164)"
.column5.DynamicBackColor ="rgb(255,255,0)"
.Column3.FontBold=.T.
.Column3.ForeColor=Rgb(128,0,64)
Locate
.Parent.Caption=Trans(Reccount())+ " records loaded"
.Refresh
Endwith
Endproc
Enddefine
*
*-- EndDefine: asup