Don't need the above End, this is enough:
TGridCracker = Class( TCustomGrid );
You're on the right track but there is no InsertRow method at all. You need
to add a row, then move it.
procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.RowCount := StringGrid1.RowCount + 1;
TGridCracker(StringGrid1).MoveRow(StringGrid1.RowCount - 1,
StringGrid1.Row);
StringGrid1.Row := StringGrid1.Row - 1;
StringGrid1.SetFocus;
end;
--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
...remove chaff when replying...
"You know you've landed gear-up when it takes full power to taxi"
type
TGridCracker = Class( TCustomGrid )
End;
...
TGridCracker.InsertRow(StringGrid1.Row);
but I get an Undeclared Identifier error.
I'd rather not use another 3rd party grid control.
___
Michael E. Fullerton | The Delphi Compendium
http://www.cyber-matrix.com/delphi.htm
procedure Register;
implementation
procedure TNohauGrid.DeleteRow(ARow: Longint);
begin
inherited DeleteRow(ARow);
end;
procedure TNohauGrid.DeleteColumn(ACol: Longint);
begin
inherited DeleteColumn(ACol);
end;
procedure TNohauGrid.MoveColumn(FromIndex, ToIndex: Longint);
begin
inherited MoveColumn(FromIndex, ToIndex);
end;
procedure TNohauGrid.MoveRow(FromIndex, ToIndex: Longint);
begin
inherited MoveRow(FromIndex, ToIndex);
end;
So, for insert you can increase Rowcount and move row to place;
and remove rows:
procedure RemoveRows(RowIndex, RCount : LongInt);
var
i: LongInt;
begin
for i := RowIndex to RowCount - 1 do Rows[i] := Rows[i + RCount];
RowCount := RowCount - RCount;
end;