Mal ein Schachrettmuster für's StringGrid:
Delphi-Quellcode:
procedure TFormMain.StringGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
with StringGrid do
begin
// Schachbrett-Muster
// Koordinaten testen (ob gerade oder ungerade)
if ((ACol mod 2 = 0) and (ARow mod 2 = 1)) or
((ARow mod 2 = 0) and (ACol mod 2 = 1)) then
begin
Canvas.Brush.Color := clMaroon;
Canvas.Font.Color := clWhite;
end;
// Füllen
Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
Canvas.FrameRect(Rect);
end;
end;