type
TNewStringGrid = class(TStringGrid)
protected
procedure Paint; override;
end;
procedure TNewStringGrid.Paint;
var
Rct: TRect;
y: Integer;
c, r: Integer;
state: TGridDrawState;
begin
// Call the inherited method, i.e. paint the grid as usual
inherited;
// Measure the rectangle of the last regular row to learn whether there's empty space below it
Rct := CellRect(0, RowCount-1);
y := Rct.Bottom;
if y < ClientHeight then
begin
// Yes, we must draw "dummy" rows...
r := RowCount;
while y < ClientHeight do begin
// Draw column by column
for c := 0 to ColCount - 1 do begin
if c < FixedCols then
state := [gdFixed]
else
state := [];
Rct := CellRect(c, RowCount-1);
Rct.Top := y;
Rct.Bottom := y + DefaultRowHeight;
PrepareCanvas(c, r, state);
DrawFillRect(Canvas, Rct);
DrawCellGrid(c, r, Rct, state);
end;
// Advance to next "dummy" row
inc(y, DefaultRowHeight);
inc(r);
end;
end;
end;