简体   繁体   中英

Get the total number of master rows and grouped rows in a DevExpress GridControl

In a previous question I posted I found out how to keep track of the currently expanded grouped rows by using 2 events:

 - gridview.GroupRowExpanded
 - gridview.GroupRowCollapsed

where I increase or decrement an integer that keeps track of how many group rows are currently expanded. I am now tackling the problem of what to do if the user expands or collapses all of the group rows. I currently know when this is done by checking the e.RowHandle .

I was wondering if there is a way to find the total number of groups rows currently in the GridView (something like rowcount for normal rows) so I know how many to set the tracking integer to.

For Example:

  • If my current count is 2 and the total number of groups are 15 then when the Expand All is fired the current count is set to 15 rather than 3.

Every detail when expanded is its own view. So to get the master row count, you can use a count of the rows in the MainView property like:

GridControl1.MainView.RowCount

To get the number of group rows:

    Dim Handle As Integer = -1  'group rows have negative row handles
    Do Until GridView1.GetRow(Handle) Is Nothing
        Handle -= 1
    Loop
    Dim count As Integer = Math.Abs(Handle + 1) 'number of group rows

Alternately, you could use your datasource & linq something like:

    Dim count As Integer = (From item As Class1 In List Group By item.Something Into AsEnumerable()).count

but as far as I am aware there is no direct property for that one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM