[ACCEPTED]-Counting the rows in a TDbGrid-datagrid

Accepted answer
Score: 14

Both RowCount and VisibleRowCount are protected properties in TCustomGrid that 3 are not exposed in TDBGrid. But you can get round 2 that doing the following:

type
  TDummyGrid = class(TDBGrid);

  RowCount := TDummyGrid(MyDBGrid).RowCount;
  VisibleRowCount := TDummyGrid(MyDBGrid).VisibleRowCount;

Be warned that 1 this includes the header.

Score: 9

You could try:

DBGrid1.DataSource.DataSet.RecordCount

Maybe there are better solutions. But 1 this worked for me.

Score: 1

I would use

TDbGrid.ApproxCount

0

More Related questions