Spread Windows Forms 11.0 Product Documentation
Grouping Event
Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > FpSpread Class : Grouping Event
Occurs when the user performs grouping.
Syntax
'Declaration
 
Public Event Grouping As GroupingEventHandler
'Usage
 
Dim instance As FpSpread
Dim handler As GroupingEventHandler
 
AddHandler instance.Grouping, handler
public event GroupingEventHandler Grouping
Event Data

The event handler receives an argument of type GroupingEventArgs containing data related to this event. The following GroupingEventArgs properties provide information specific to this event.

PropertyDescription
Determines whether to cancel the grouping.  
Gets or sets the group comparer.  
Gets the sorting information.  
Remarks

This event is raised by the OnGrouping method when the user groups rows.

Example
This example uses the Grouping event.
fpSpread1.Sheets[0].RowCount = 8;
fpSpread1.Sheets[0].ColumnCount = 15;
fpSpread1.Sheets[0].GroupBarInfo.Visible = true;
fpSpread1.Sheets[0].AllowGroup = true;
fpSpread1.Sheets[0].GroupFooterVisible = true;
fpSpread1.Sheets[0].ColumnFooter.Visible = true;
fpSpread1.Sheets[0].ColumnFooter.RowCount = 2;
fpSpread1.Sheets[0].ColumnFooter.Columns[12].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left;
fpSpread1.Sheets[0].ColumnFooter.Cells[0, 12].RowSpan = 2;
//Value

for (int r = 0; r < fpSpread1.Sheets[0].RowCount; r++)
{
    for (int j = 0; j < fpSpread1.Sheets[0].ColumnCount; j++)
    {
        fpSpread1.Sheets[0].Models.Data.SetValue(r, j, j + r * fpSpread1.Sheets[0].ColumnCount);
    }
}

int i = 0;
fpSpread1.Sheets[0].ColumnFooter.SetAggregationType(0, 1, FarPoint.Win.Spread.Model.AggregationType.Sum);
fpSpread1.Sheets[0].ColumnFooter.Cells[0, i].Value = "Sum";

private void fpSpread1_Grouping(object sender, FarPoint.Win.Spread.GroupingEventArgs e)
        {
            listBox1.Items.Add("grouping");
        }
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
fpSpread1.Sheets(0).RowCount = 8
fpSpread1.Sheets(0).ColumnCount = 15
fpSpread1.Sheets(0).GroupBarInfo.Visible = True
fpSpread1.Sheets(0).AllowGroup = True
fpSpread1.Sheets(0).GroupFooterVisible = True
fpSpread1.Sheets(0).ColumnFooter.Visible = True
fpSpread1.Sheets(0).ColumnFooter.RowCount = 2
fpSpread1.Sheets(0).ColumnFooter.Columns(12).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Left
'Value
Dim r As Integer
Dim j As Integer
For r = 0 To fpSpread1.Sheets(0).RowCount
    For j = 0 To fpSpread1.Sheets(0).ColumnCount
        fpSpread1.Sheets(0).Models.Data.SetValue(r, j, j + r * fpSpread1.Sheets(0).ColumnCount)
    Next j
Next r
Dim i As Integer
i = 0
fpSpread1.Sheets(0).ColumnFooter.SetAggregationType(0, 1, FarPoint.Win.Spread.Model.AggregationType.Sum)
fpSpread1.Sheets(0).ColumnFooter.Cells(0, i).Value = "Sum"
    End Sub

    Private Sub fpSpread1_Grouping(sender As Object, e As FarPoint.Win.Spread.GroupingEventArgs) Handles fpSpread1.Grouping
ListBox1.Items.Add("grouping")
    End Sub
See Also