<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Dear Mr. Dave:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am a new one in FP but I have some years in
Delphi.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>for coloring stringgrid´cells I use the
following routine:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>procedure
TfBasica829.StringGrid2PrepareCanvas(sender: TObject; aCol,<BR> aRow:
Integer; aState: TGridDrawState);<BR>var<BR> aTextStyle:
TTextStyle;<BR>begin<BR>{<BR>clRed, clGreen, clYellow, clBlue,<BR>clWhite,
clGray, clFuchsia, clTeal,<BR>clNavy, clMaroon, clLime, clOlive,<BR>clPurple,
clSilver, clAqua, clBlack<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> if (ACol=0)
then //1<BR>
begin<BR>
Stringgrid2.Canvas.Brush.Color := clRed;
//<BR> aTextStyle :=
StringGrid2.Canvas.TextStyle;<BR>
aTextStyle.Alignment:=taCenter;
//taRightJustify;<BR>
aTextStyle.Layout:=tlCenter;
//tlBottom;<BR>
StringGrid2.Canvas.TextStyle := aTextStyle;<BR>
end<BR> else<BR> if ACol=1
then //1.5<BR>
begin<BR>
Stringgrid2.Canvas.Brush.Color := clOlive{Green};
//<BR> aTextStyle :=
StringGrid2.Canvas.TextStyle;<BR>
aTextStyle.Alignment:=taCenter;
//taRightJustify;<BR>
aTextStyle.Layout:=tlCenter;
//tlBottom;<BR>
StringGrid2.Canvas.TextStyle := aTextStyle;<BR>
end<BR> else<BR> if ACol=2
then //2<BR>
begin<BR>
Stringgrid2.Canvas.Brush.Color := clYellow;
//<BR> aTextStyle :=
StringGrid2.Canvas.TextStyle;<BR>
aTextStyle.Alignment:=taCenter;
//taRightJustify;<BR>
aTextStyle.Layout:=tlCenter;
//tlBottom;<BR>
StringGrid2.Canvas.TextStyle := aTextStyle;<BR>
end<BR> else<BR> if ACol=3
then //2.5<BR>
begin<BR>
Stringgrid2.Canvas.Brush.Color := clAqua;
//<BR> aTextStyle :=
StringGrid2.Canvas.TextStyle;<BR>
aTextStyle.Alignment:=taCenter;
//taRightJustify;<BR>
aTextStyle.Layout:=tlCenter;
//tlBottom;<BR>
StringGrid2.Canvas.TextStyle := aTextStyle;<BR>
end<BR> else<BR> if ACol=4
then //3.0<BR>
begin<BR>
Stringgrid2.Canvas.Brush.Color := clSilver;
//<BR> aTextStyle :=
StringGrid2.Canvas.TextStyle;<BR>
aTextStyle.Alignment:=taCenter;
//taRightJustify;<BR>
aTextStyle.Layout:=tlCenter;
//tlBottom;<BR>
StringGrid2.Canvas.TextStyle := aTextStyle;<BR>
end;<BR>end;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>to obtain this</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><IMG alt="" hspace=0
src="cid:003101c8e672$379a79f0$20dcdcc9@hfiandor" align=baseline
border=0></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>maybe this can help you.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>bye,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Ing. Héctor F. Fiandor<BR><A
href="mailto:hfiandor@infomed.sld.cu">hfiandor@infomed.sld.cu</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----- Original Message ----- </FONT>
<DIV><FONT face=Arial size=2>From: "Dave Coventry" <</FONT><A
href="mailto:dgcoventry@gmail.com"><FONT face=Arial
size=2>dgcoventry@gmail.com</FONT></A><FONT face=Arial size=2>></FONT></DIV>
<DIV><FONT face=Arial size=2>To: "General mailing list" <</FONT><A
href="mailto:lazarus@lazarus.freepascal.org"><FONT face=Arial
size=2>lazarus@lazarus.freepascal.org</FONT></A><FONT face=Arial
size=2>></FONT></DIV>
<DIV><FONT face=Arial size=2>Sent: Tuesday, July 15, 2008 7:15 AM</FONT></DIV>
<DIV><FONT face=Arial size=2>Subject: [Lazarus] Colouring
StringGrids</FONT></DIV></DIV>
<DIV><FONT face=Arial><BR><FONT size=2></FONT></FONT></DIV><FONT face=Arial
size=2>> Hi,<BR>> <BR>> I'm using the following code to
(unsuccessfully) colour the fields of<BR>> a row in a tstringgrid if the
second column is empty.<BR>> <BR>> if
StringGrid2.Cells[1,i]='' then<BR>>
begin<BR>>
PriceHeader:=true;<BR>>
StringGrid2.Repaint;<BR>> end;<BR>> <BR>>
<BR>> procedure TForm1.StringGrid2DrawCell(Sender: TObject; aCol, aRow:
Integer;<BR>> aRect: TRect; aState: TGridDrawState);<BR>> var
oldColour:TColor;<BR>> oldBrush: TBrush;<BR>> begin<BR>>
with StringGrid2 do<BR>> begin<BR>> if PriceHeader
then<BR>> begin<BR>>
oldcolour:=font.Color;<BR>>
oldBrush:=Canvas.Brush;<BR>>
Brush.Color:=clNavy;<BR>>
font.Color:=clWhite;<BR>>
Canvas.FillRect(aRect);<BR>>
font.Color:=oldColour;<BR>>
Canvas.Brush:=oldBrush;<BR>>
PriceHeader:=false;<BR>> end;<BR>> end;<BR>>
end;<BR>> <BR>> Can anyone give me a clue as to why it's not
working?<BR>> _______________________________________________<BR>> Lazarus
mailing list<BR>> </FONT><A
href="mailto:Lazarus@lazarus.freepascal.org"><FONT face=Arial
size=2>Lazarus@lazarus.freepascal.org</FONT></A><BR><FONT face=Arial size=2>>
</FONT><A
href="http://www.lazarus.freepascal.org/mailman/listinfo/lazarus"><FONT
face=Arial
size=2>http://www.lazarus.freepascal.org/mailman/listinfo/lazarus</FONT></A><BR><FONT
face=Arial size=2>> <BR>> __________ Información de ESET Smart Security,
versión de la base de firmas de virus 3268 (20080715) __________<BR>>
<BR>> ESET Smart Security ha comprobado este mensaje.<BR>> </FONT><A
href="http://www.eset.com"><FONT face=Arial
size=2>http://www.eset.com</FONT></A><BR><FONT face=Arial size=2>>
<BR>></FONT></BODY></HTML>