Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting the rows in a TDbGrid

I have a TDbGrid, and I can easily tell how many columns are in it at runtime with the FieldCount property, but there doesn't seem to be a corresponding RowCount property to display how many records are being displayed. How can I find this out?

like image 734
Mason Wheeler Avatar asked Nov 16 '08 20:11

Mason Wheeler


1 Answers

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

type
  TDummyGrid = class(TDBGrid);

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

Be warned that this includes the header.

like image 114
Steve Avatar answered Sep 25 '22 03:09

Steve