unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Menus;
type
TForm1 =
class(TForm)
...
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
farbe:tcolor;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
farbe:=clyellow;
stringgrid1.Ondrawcell:= StringGrid1DrawCell;
stringgrid2.Ondrawcell:= StringGrid2DrawCell;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if not Odd(Arow)
and not (gdFixed
in State)
then
with StringGrid1
do
begin
Canvas.Brush.Color := farbe;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+2, Rect.Top+2, Cells[Acol, ARow]);
end;
end;
procedure TForm1.StringGrid2DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if not Odd(Arow)
and not (gdFixed
in State)
then
with StringGrid2
do
begin
Canvas.Brush.Color := farbe;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+2, Rect.Top+2, Cells[Acol, ARow]);
end;
end;
procedure TForm1.Farbe1Click(Sender: TObject);
begin
if colordialog1.execute
then
farbe:=colordialog1.Color;
stringgrid1.OnDrawCell:=StringGrid1DrawCell;
stringgrid2.OnDrawCell:=StringGrid2DrawCell;
end;
end.