Ticket Q136118
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Count group rows

Get number of group rows in the GridView

created 16 years ago

Hello,
I need to get a number of group rows in the grid view. The RowCount property provides a total number of rows including data rows and group rows no matter whether group rows are collapsed or expanded. Now, i need to run through all data rows and i didn't find a better way than going from 0 to RowCount and operate the index like it is row handle. However, when i have groups at the end of the iterating i have to check whether the handle is valid. In some cases i need to interate through group rows in the same way and there i'm running from -1 back until i get invalid row. Is there any more conventional way that provides total number of group rows?
Regards, Leo

Comments (3)
DevExpress Support Team 16 years ago

    Hello Leo,
    You can use this function to obtain a group row count:

    C#
    private static int GetGroupRowCount(DevExpress.XtraGrid.Views.Grid.GridView view) { for(int i = -1; i >= int.MinValue; i--) { if(!view.IsValidRowHandle(i)) return -(i + 1); } return 0; }

    Thanks,
    Nick

      Thank you. In other words there is no such information. I'd already discovered the suggested trick, but i's hoping that the value exist and doesn't require tricks. :(
      Leo.

      DevExpress Support Team 16 years ago

        Hello Leo,
        This is a recommended solution. I believe that this solution is not so complex to provide an additional method for the grid.
        Thank you,
        Paul

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.