Re: Adding rows to a TStringGrid
From: AlanGLLoyd (alanglloyd_at_aol.com)
Date: 10/14/04
- Next message: David Reeve: "Re: Reading serial port lines"
- Previous message: Bjørge Sæther: "Re: Is it possible to open a file for reading or writing using UNC names in later Delphi versions"
- In reply to: QS Computing: "Adding rows to a TStringGrid"
- Next in thread: QS Computing: "Re: Adding rows to a TStringGrid"
- Reply: QS Computing: "Re: Adding rows to a TStringGrid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 14 Oct 2004 08:39:25 GMT
There is a protected method of TCustomGrid which is not exposed in TStringgrid.
You may expose it by declaring a descendant class and typecasting the
stringgrid to that class, Then you can increase the SG.RowCount and move the
last row to where you want it. Use LockWindowUpdate to improve speed of insert
and redrawing ...
type
TMoveRowSG = class(TStringGrid); // declare descendant
procedure TForm1.InsertSGRow(SG : TStringGrid; RowOrigin : integer;
InsertBefore : boolean);
begin
LockWindowUpdate(SG.Handle); // prevent incremental drawing of SG
{add row at end}
SG.RowCount := SG.RowCount + 1;
{move row to defined position}
if InsertBefore then
TMoveRowSG(SG).MoveRow(SG.RowCount - 1, RowOrigin)
else
if RowOrigin < SG.RowCount - 2 then // don't move row to same place
TMoveRowSG(SG).MoveRow(SG.RowCount - 1, RowOrigin + 1);
LockWindowUpdate(0); // redraw all SG now
end;
Alan Lloyd
alanglloyd@aol.com
- Next message: David Reeve: "Re: Reading serial port lines"
- Previous message: Bjørge Sæther: "Re: Is it possible to open a file for reading or writing using UNC names in later Delphi versions"
- In reply to: QS Computing: "Adding rows to a TStringGrid"
- Next in thread: QS Computing: "Re: Adding rows to a TStringGrid"
- Reply: QS Computing: "Re: Adding rows to a TStringGrid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]