private int VisibleRowCountExact()
{
int ydiff = 0;
RowCollection rows = this.TableModel.Rows;
int visibleHeight = this.CellDataRect.Height;
int count = 0;
for (int i = this.TopIndex; i < rows.Count; i++)
{
// Don't count this row if it is currently a hidden subrow
Row row = rows[i];
if (row != null && (row.Parent == null || row.Parent.ExpandSubRows))
{
ydiff += row.Height;
if (ydiff < visibleHeight)
count++;
else
break;
}
}
return count;
}