1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| procedure TForm1.FormCreate(Sender: TObject);
var
i : Integer;
begin
with SG1 do begin
RowCount := 21;
for i := 1 to RowCount -1 do
Cells[1, i] := IntToStr(i);
end;
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
var
sText : String;
begin
if aCol > 0 then
if aRow > 0 then
if not (gdSelected in aState) then
with SG1 do
if StrToInt(Cells[1, aRow]) mod 4 = 0 then begin
sText := Cells[aCol, aRow];
with CanVas do begin
brush.color := clGreen;
FillRect(aRect);
TextRect(aRect, aRect.Left + (aRect.Right - aRect.Left) shr 1
- (TextWidth(sText) shr 1), aRect.Top +3, sText);
end;
end;
end; |