Back to Devexpress

GridView.GroupSummarySortInfo Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-e5d51239.md

latest5.5 KB
Original Source

GridView.GroupSummarySortInfo Property

Enables sorting group rows by summary values.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[Browsable(false)]
public GroupSummarySortInfoCollection GroupSummarySortInfo { get; }
vb
<Browsable(False)>
Public ReadOnly Property GroupSummarySortInfo As GroupSummarySortInfoCollection

Property Value

TypeDescription
GroupSummarySortInfoCollection

A GroupSummarySortInfoCollection collection which contains the information required to sort group rows by summary values.

|

Remarks

Use the GroupSummarySortInfo property to sort group rows by summary values. This property represents a collection of GroupSummarySortInfo objects that specify the nesting level of the group rows that are to be sorted by the summary values and, the sort order and summary item which is used to calculate the summary values for groups of rows.

To sort group rows by summary values, you should create a new GroupSummarySortInfo object with the specified settings, and add it to the GridView.GroupSummarySortInfo collection, using the GroupSummarySortInfoCollection.Add method.

To cancel sorting the group rows by summary values, remove the corresponding GroupSummarySortInfo object from the collection. Note that GroupSummarySortInfo objects are automatically removed from the collection, after the sort order of the corresponding group columns has been changed.

If group summaries are created and the GridOptionsMenu.ShowGroupSortSummaryItems option is enabled, an end-user can sort group rows by the group summary values via a context menu. This is accomplished by right-clicking a grouping column’s header, and then selecting a corresponding command from the context menu:

For more information on sorting group rows by summary values, see the Summaries document.

Example

The following example shows how to sort the group rows that reside at the first grouping level by summary values. The group summaries are calculated by the Freight column’s values.

The image below shows the result.

csharp
using DevExpress.Data;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;

GridSummaryItem summaryItemMaxFreight;
private void Form1_Load(object sender, System.EventArgs e) {
   // ...
   // Creating a new summary item and adding it the view's summary item collection.
   summaryItemMaxFreight = gridView1.GroupSummary.Add(SummaryItemType.Max, 
     "Freight", null, String.Empty);
}

private void button1_Click(object sender, System.EventArgs e) {
   GridColumn summaryColumn = gridView1.Columns["Freight"];
   if(summaryColumn.GroupIndex < 0 && gridView1.GroupCount > 0) {
      GridColumn firstGroupingColumn = gridView1.SortInfo[0].Column;
      gridView1.GroupSummarySortInfo.Add(summaryItemMaxFreight, 
        ColumnSortOrder.Ascending, firstGroupingColumn);
   }
}
vb
Imports DevExpress.Data
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns

Dim summaryItemMaxFreight As GridSummaryItem
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
    ' ...
    ' Creating a new summary item and adding it the view's summary item collection.
    summaryItemMaxFreight = GridView1.GroupSummary.Add(SummaryItemType.Max, _
      "Freight", Nothing, String.Empty)
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Button1.Click
    Dim summaryColumn As GridColumn = GridView1.Columns("Freight")
    If summaryColumn.GroupIndex < 0 And GridView1.GroupCount > 0 Then
        Dim firstGroupingColumn As GridColumn = GridView1.SortInfo(0).Column
        GridView1.GroupSummarySortInfo.Add(summaryItemMaxFreight, _
          ColumnSortOrder.Ascending, firstGroupingColumn)
    End If
End Sub

See Also

ShowGroupSortSummaryItems

Summaries

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace