Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
705
grouping gives improper recordcount
posted

I need to pull the total number of rows that is in a grid.  I normally use this property:

ultraGrid.Rows.Count.ToString();

It works unless the user is using a group by on a column.  So if using the group by breaks the records into two groups the property above gives me "2" instead of the actual number of records that are in the grid.

Help!

  • 45049
    Verified Answer
    posted

    When you group a grid, the grid's Rows collection contains instances of group-by rows (class UltraGridGroupByRow), rather than rows representing your data.  Because of this, it's expected that the grid's Rows.Count property will return the number of groups you have.

    Instead, use the grid's Rows.GetFilteredInNonGroupByRowCount property.  This will also remove from your count any rows that were filtered out.

    If you need to include rows that were filtered out, you can use the Rows.GetAllNonGroupByRows() method to get an array of all non-group-by rows, and then look up the Length of that array.