Merhaba
Aşağıdaki koda bir bakın (Usenet'de bir delphi grubundan buldum, denedim çalışıyor. Bir form hazırlayıp içine bir string grid koyup stringgrid'in ondrawcwell hadisesine atamanız lazım StringGrid1DrawCell isimli prosedürü) :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
Button1: TButton;
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
var
OldColor : TColor;
OldBrush : TBrush;
begin with StringGrid1.Canvas do begin
OldColor := Font.Color;
OldBrush := Brush;
{paint fridays}
if StringGrid1.Cells[ACol,1] = 'Fr' then begin
Brush.Color := $02aaaaaa; {light gray}
FillRect(Rect);
Font.Color := clWhite;
TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
end;
{paint each alternating month}
if (ARow = 0) and (ACol > 0) then begin
if (Odd(StrToIntDef(StringGrid1.Cells[ACol,31],0))) then
Brush.Color := clBlue
else
Brush.Color := clFuchsia;
FillRect(Rect);
Font.Color := clWhite;
TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
end;
{paint days of the week}
if (ARow = 1) and (ACol > 0) then begin
if StringGrid1.Cells[ACol,1] = 'Fr' then
Brush.Color := clTeal else
Brush.Color := clAqua;
FillRect(Rect);
if StringGrid1.Cells[ACol,1] = 'Fr' then
Font.Color := clWhite else
Font.Color := clBlack;
TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
end;
Font.Color := OldColor;
Brush := OldBrush;
end;
end;
end.