Getting Started with Windows Forms GridGrouping
30 May 20238 minutes to read
This section will explain about creating simple GridGroupingControl and the overview of its basic functionalities.
Choosing the Best Grid
Essential Grid includes a trio of grid controls as well as many other controls that are used in conjunction with these three grids. Essential Grid works similar to Microsoft Excel and allows extremely detailed customization down to the cell level. Multi-level Undo / Redo, Shared Scrollbar support, Data / View separation, floating cells, more than 15 cell types, and unmatched extensibility are the unique features of the Essential Grid.
GridGroupingControl: A high performance grouping grid that offers very flexible support for grouping flat data sources as well as hierarchical data sources. This grid supports expressions fields, filters, multi-column sorting, grouping, nested tables/hierarchies, and custom summaries. It can use any IList data source including ADO.NET DataSet/DataTables and IBindingList objects.
GridDataBoundGrid: A column oriented grid best suited for use with ADO.NET DataSet/DataTables data sources. If you are looking to bind with the ADO.NET
data source without the grouping and hierarchical support then you can use GridDataBoundGrid. GridDataBoundGrid is marked as classic because all the features mentioned in this are available in GridGroupingControl
with more efficiency and features.
GridControl: A cell oriented grid that contain its own data. Does not need to be bound to a data source. Easily customize down to the cell level. Used in a virtual manner such that, it can bind to any type of data source.
SfDataGrid: Designed based on column-oriented architecture that provides support to customize the grid easily. Display collection of data in rows and columns.
Control |
Grouping |
Sorting |
Summary |
Filtering |
Export |
---|---|---|---|---|---|
GGC |
Yes |
Yes |
Yes |
Yes |
Yes |
GDBG |
- |
Yes |
- |
Yes |
Yes |
GC |
- |
* |
- |
* |
Yes |
SfDataGrid |
Yes |
Yes |
Yes |
Yes |
Yes |
NOTE
The
*
denotes that by default, support is not provided to the Control. It will be added by having some customizations. The Sorting and Filtering functionalities can be added to theGridControl
by doing some customizations.
For binding the different kind of data sources and support for filtering, sorting, grouping for flat and hierarchical data sources make use of the GridGroupingControl
.
If user wants a cell oriented grid that can contain its own data and does not need to be bound to a data source then GridControl
is the best choice
If the user wants the support for filtering, sorting, grouping, summary calculation and hierarchical data sources with the blazing performance, the SfDataGrid
control is one of the best choice.
Assembly Deployment
Refer control dependencies section to get the list of assemblies or NuGet package needs to be added as reference to use the control in any application.
Configuring a simple GridGroupingControl
This section will explain how to create a simple GridGroupingControl in Windows Forms application and some of the basic functionalities of it.
Adding GridGroupingControl through Designer
GridGroupingControl can be added through designer by following the below steps.
-
Create a new Windows Form Application.
-
Drag and Drop GridGroupingControl from the toolbox into the designer page.
-
Once drag drop the GridGroupingControl into the designer page, the GridGroupingControl will be added successfully into the application with the required libraries. The below mentioned assemblies will be added automatically into the application.
- Syncfusion.Grid.Base.dll
- Syncfusion.Grid.Grouping.Base.dll
- Syncfusion.Grid.Grouping.Windows.dll
- Syncfusion.Grid.Windows.dll
- Syncfusion.Grouping.Base.dll
- Syncfusion.Shared.Base.dll
- Syncfusion.Shared.Windows.dll
Adding GridGroupingControl through Code
GridGroupingControl can be added through code-behind by following the below steps.
-
Create a new Windows Form Application.
-
Add the below assemblies into the project file
- Syncfusion.Grid.Windows.dll
- Syncfusion.Grid.Grouping.Windows.dll
- Syncfusion.Grouping.Base.dll
- Syncfusion.Shared.Base.dll
-
Initialize a GridGroupingControl by using the below code in code behind.
//Initializing a new GridGroupingControl.
private Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl gridGroupingControl1;
'Initializing a new GridGroupingControl.
Private gridGroupingControl1 As New Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl()
- Use the below code for adding the initialized GridGroupingControl to the application.
//Add required size for the Grid.
this.gridGroupingControl1.Size = new System.Drawing.Size(130, 80);
this.Controls.Add(this.gridGroupingControl1);
'Add required size for the Grid.
Me.gridGroupingControl1.Size = New System.Drawing.Size(130, 80)
Me.Controls.Add(Me. gridGroupingControl1)
Populating Data
GridGroupingControl supports variety of data sources such as DataTables, DataSets, or any component that implement interfaces like IList, IBindingList, ITypedList, or IListSource. The data source can have multiple nested tables, which will be displayed hierarchically by GridGroupingControl. For assigning the data source to GridGroupingControl, DataSource property needs to be used.
// Adds the data source to the GridGroupingControl
this.gridGroupingControl1.DataSource = this.dataset11.Employees;
'Adds the data source to the GridGroupingControl.
Me.gridGroupingControl1.DataSource = Me.dataset11.Employees
Refer the Data Binding topic for more detailed explanation on how to bind data source to GridGroupingControl.
Editing
By default, GridGroupingControl is in editable state. Editing can be enabled/disabled by using the ActivateCurrentCellBehavior property.
// Disables editing in GridGroupingControl
this.gridGroupingControl1.ActivateCurrentCellBehavior = GridCellActivateAction.None;
' Disables editing in GridGroupingControl
Me.gridGroupingControl1.ActivateCurrentCellBehavior = GridCellActivateAction.None
Editing operations can be customized by using the TableControlCurrentCellStartEditing and TableControlCurrentCellEditingComplete events. Check theEditing topic for more information on methods and properties related to it.
Grouping
GridGroupingControl allows to group data by one or more columns. Data will be organized into a hierarchical structure based on the matching field values.
If grouping is enabled in GridGroupingControl then there will be a specific area at the top of the Grid which shows the grouping options. This area is known as the GridGroupDropArea. GridGroupDropArea
is made up of collection of grid controls packed in a panel named GroupDropPanel. GridGroupDropArea
can be enabled by using the ShowGroupDropArea property.
// Allows GroupDropArea to be visible
this.gridGroupingControl1.ShowGroupDropArea = true;
' Allows GroupDropArea to be visible
Me.gridGroupingControl1.ShowGroupDropArea = True
Check the Grouping topic, to know more information regarding grouping.
Sorting
Sorting can be done in GridGroupingControl by just clicking the column header of the grid. It can be configured by using the AllowSortColumns property. By default, sorting will be enabled in GridGroupingControl. Refer the Sorting topic for detailed explanation.
' Enables sorting in GridGroupingControl.
Me.gridGroupingControl1.TableOptions.AllowSortColumns = True
Filtering
GridGroupingControl is specially designed for supporting the filtering options. It supports three types of filtering namely Normal Filter, Excel-Like Filter and Dynamic Filter. To enable the Filter in GridGroupingControl make use of the AllowFilter property. Refer the Filtering topic for detailed explanation.
// Enable Filtering for the 3rd column.
this.gridGroupingControl1.TableDescriptor.Columns[3].AllowFilter = true;
'Enable Filtering for the 3rd column.
Me.gridGroupingControl1.TableDescriptor.Columns(3).AllowFilter = True