Author: Radikal Q3
Show several color in the rows of a TStringGrid.
Answer:
Using the OnDrawCell event...
Put this code in the event OnDrawCell of the StringGrid:
1 2 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
3 Rect: TRect; State: TGridDrawState);
4 begin5 with (Sender as TStringGrid) dobegin6 if (Arow and 1)=1 then Canvas.Font.Color := clRed { En rojo / in red }7 else Canvas.Font.Color := clBlue; { En Azul / in Blue }8 9 Canvas.TextRect( Rect,
10 Rect.Left + 2,
11 Rect.Top + 2,
12 Cells[Acol,Arow]);
13 end;
14 end;
This example shows the even lines with a color and the odd with other...