unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 =
class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1Click(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.StringGrid1Click(Sender: TObject);
var i,j : integer;
begin
for i := 0
to Stringgrid1.ColCount - 1
do
for j := 0
to Stringgrid1.RowCount - 1
do
Stringgrid1.Cells [i,j] := IntToStr (i)+'
'+IntToStr (j);
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with Stringgrid1
do begin
if ARow
mod 2 = 0
then begin
Canvas.Brush.Color := clRed;
Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[Acol, Arow]);
end;
end;
end;
end.