| Data Presentation Techniques > Column Grouping > Column Grouping with the GroupIntervalEnum Enumeration > Group Rows by Date Value (Outlook-Style) |
This topic demonstrates how to use the GroupIntervalEnum.DateSpan member in C1TrueDBGrid.
![]() |
Note: The C1NWind.mdb database was modified for this example. A field NextMeeting was added to the employees table and filled in with more current dates. |
Complete the following steps:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.EmployeesTableAdapter.Fill(Me.Employees._Employees) |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.employeesTableAdapter.Fill(this.Employees._Employees); |
|
In the Designer
In the C1TrueDBGrid Tasks menu, select GroupBy from the Data Layout drop-down list:
In Code
Add the following code to the Form_Load event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy; |
|
The column can also be selected by choosing NextMeeting from the drop-down list in the toolbar.
In the Designer
Locate the Interval property in the left pane of the C1TrueDBGrid Designer and set it to DateSpan.
In Code
Add the following code to the Form_Load event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' Set the GroupInfo.Interval of the grid to DateSpan.
Me.C1TrueDBGrid1.Columns("NextMeeting").GroupInfo.Interval = C1.Win.C1TrueDBGrid.GroupIntervalEnum.DateSpan
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// Set the GroupInfo.Interval of the grid to DateSpan. this.c1TrueDBGrid1.Columns["NextMeeting"].GroupInfo.Interval = C1.Win.C1TrueDBGrid.GroupIntervalEnum.DateSpan; |
|
In the Designer
Locate the ColumnVisible property in the left pane of the C1TrueDBGrid Designer and set it to True.
In Code
Add the following code to the Form_Load event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' Keep the NextMeeting column visible while grouping.
Me.C1TrueDBGrid1.Columns("NextMeeting").GroupInfo.ColumnVisible = True
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// Keep the NextMeeting column visible while grouping. this.c1TrueDBGrid1.Columns["NextMeeting"].GroupInfo.ColumnVisible = true; |
|
In this example, the NextMeeting column is sorted by date values.