[Lazarus] Colouring StringGrids
Michael Van Canneyt
michael at freepascal.org
Tue Jul 15 15:15:49 CEST 2008
On Tue, 15 Jul 2008, Dave Coventry wrote:
> Hi,
>
> I'm using the following code to (unsuccessfully) colour the fields of
> a row in a tstringgrid if the second column is empty.
>
> if StringGrid2.Cells[1,i]='' then
> begin
> PriceHeader:=true;
> StringGrid2.Repaint;
> end;
This kind of logic should only be used in the PrepareCanvas or DrawCall
events.
>
>
> procedure TForm1.StringGrid2DrawCell(Sender: TObject; aCol, aRow: Integer;
> aRect: TRect; aState: TGridDrawState);
> var oldColour:TColor;
> oldBrush: TBrush;
> begin
I would insert here
PriceHeader:=(ACol=1) and (ARow=Something) and (Cells[ACol,Something]='');
And make PriceHeader a local variable.
Michael.
More information about the Lazarus
mailing list