Оффтоп:
Цитата:
Сообщение от kossr
...Спасибо за многочисленные ответы.
|
И вам того же, за оригинальный и самое главное, редкий, никем не разжёванный ранее вопрос
По теме:
Цитата:
...OnDrawCell использовать только чтобы сохранять раскраску...
|
Да нет, не сохранять, всё самое интересное в DrawCell как раз и происходит
Код:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
fcl, bcl: TColor;
fcs: TFontStyles;
begin
with StringGrid1.Canvas do
begin
fcl:= Font.Color; fcs:= Font.Style; bcl:= Brush.Color;
if gdSelected in State then
begin
Font.Color:= TColor($FFFFFF);
Font.Style:= Font.Style + [fsBold];
Brush.Color:= clGreen;
end else
if ARow < StringGrid1.FixedRows then
begin
Font.Color:= TColor($000000);
Font.Style:= Font.Style + [fsBold];
Brush.Color:= TColor($00FFFF);
end else
if ACol < StringGrid1.FixedCols then
begin
Font.Color:= clBlack;
Font.Style:= Font.Style + [fsBold];
Brush.Color:= clLime;
end else
if ARow mod 2 = 0 then
begin
Font.Color:= RGB(0, 0, 0);
Brush.Color:= clPurple;
end else
begin
Font.Color:= RGB(0, 0, 0);
Brush.Color:= RGB($CC, $FF, $FF);
end;
FillRect(Rect);
TextOut(Rect.Left+4,Rect.Top+4,StringGrid1.Cells[ACol,ARow]);
Font.Color:= fcl; Font.Style:= fcs; Brush.Color:= bcl;
end;
end;