If you want to add colour coding to a grid to be able to visually differentiate between records and/or cells, add 2 new fields [color blue](fore_color C(11), back_color C(11))[/color] to the [color blue].RecordSource[/color] table of Grid1.
Add a new form method called [color blue].mGridColours()[/color] and a new form property called [color blue].nRecNo[/color].
In the [color blue].Init[/color] event of Grid1 put:-
[color blue]
THISFORM.nRecNo = RECN([TABLENAME])
THIS.Refresh()
[/color]
In the [color blue].AfterRowColChange()[/color] event of Grid1 put:-
[color blue]
THISFORM.nRecNo = RECN([TABLENAME])
THIS.Refresh()
[/color]
In the [color blue].Column[/color](s) of the grid set [color blue].Sparse = .F.[/color] and [color blue].DynamicCurrentControl = THISFORM.mGridColours()[/color].
In the [color blue].mGridColours()[/color] method put:-
[color blue]
WITH THISFORM.Grid1
[tab]DO CASE
[tab]CASE THISFORM.nRecNo = RECN([TABLENAME])
[tab][tab].Column1.Text1.Forecolor = RGB(255,255,255)
[tab][tab].Column1.Text1.Backcolor = RGB(0,0,128)
[tab]CASE TABLENAME.fore_color = [R/W]
[tab][tab].Column1.Text1.Forecolor = RGB(255,0,0)
[tab][tab].Column1.Text1.Backcolor = RGB(255,255,255)
[tab]CASE TABLENAME.fore_color = [B/W]
[tab][tab].Column1.Text1.Forecolor = RGB(0,255,0)
[tab][tab].Column1.Text1.Backcolor = RGB(255,255,255)
[tab]CASE TABLENAME.fore_color = [G/W]
[tab][tab].Column1.Text1.Forecolor = RGB(0,0,255)
[tab][tab].Column1.Text1.Backcolor = RGB(255,255,255)
[tab]ENDC
ENDW
[/color]
You will find the [color blue].Forecolor[/color] properties of the cells will reflect the value selected by [color blue]TABLENAME.fore_color[/color], with the currently selected record highlighted.
If you want the fields [color blue]TABLENAME.fore_color[/color] and [color blue]TABLENAME.back_color[/color] to determine the colours displayed, then :-
[color blue]
[tab]DO CASE
[tab]CASE ALLT(TABLENAME.fore_color) = [255,255,0]
[tab][tab]lcColor = [.Column1.Text1.Forecolor = RGB(]+ALLT(TABLENAME.fore_color)+[)]
[tab][tab]&lcColor
[tab][tab]lcColor = [.Column1.Text1.Backcolor = RGB(]+ALLT(TABLENAME.back_color)+[)]
[tab][tab]&lcColor
[tab]ENDC[/color]
FAQ184-2483 - answering getting answered.
Chris
[link http://www.pdfcommander.net]PDFcommander[sup]tm[/sup].net[/link]
[link http://www.pdfcommander.net]PDFcommander[sup]tm[/sup].com[/link]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.