| Tutorials > Tutorial 23 - Outlook-Style Grouping (OLEDB Only) |
In this tutorial, you will learn how to use the Outlook-Style Grouping feature.
The purpose of outlook-style grouping is to allow you to move list columns into a new split for enhanced data display capabilities. When in Group mode, a "grouping area" is added to the list, providing an intuitive interface for creating a columns group.
When DataView is set to 2 - Group, and AllowColMove is set to True, the list will support the ability to group columns into the grouping area. This action can be performed by users at run time by selecting a column and dragging its header into the grouping area. This action can also be performed in code at run time by invoking the Add method of the GroupColumns collection. Use the Remove method of the GroupColumns collection at run time to remove a column from the grouping area.
See Outlook-Style Grouping for more information.
![]() |
The DataView property is only supported by the OLE DB version of True DBList. |
Start a new project.
From the Visual Basic Project menu, select Components, then check the boxes labeled ComponentOne True DBList Pro 8.0 (OLEDB) and Microsoft ADO Data Control 6.0 (OLEDB).
Place an ADO Data control (Adodc1) and a True DBList control (TDBList1) on the form (Form1).
Display the custom property pages for Adodc1. Click the General tab and select the Use Connection String option. Click Build. The "Microsoft Jet 3.51 Provider" option should be highlighted. Click Next>>. Enter the datasource name (C:PROGRAM FILES\TDBL7\TUTORIALS\TDBLDEMO.MDB) in the Use Data source name text box. You do not have to enter a user name or password. Test the connection to make sure it works. Close the dialog window. Click the OK button to close the property page.
Set the CommandType (Data control) property to 2 - adCmdTable.
Set the RecordSource (Data control) property to Composer.
Set the RowSource property of TDBList1 to Adodc1.
Set the RowDividerStyle to 2 - Dark gray line.
Set the DataView property of TDBList1 to 2 - Group
Open the Property Pages dialog box. Select the Splits property page by clicking the Splits tab. Expand the Splits(00) object and set the AllowColMove property to True. Click the OK button at the bottom of the Property Pages dialog box to accept the changes. You have now finished configuring the list. The list should look like the one in the following figure.

Add the following code to GroupColMove event of TDBList1:
| Example Title |
Copy Code
|
|---|---|
Private Sub TDBList1_GroupColMove(ByVal Position As Integer, ByVal ColIndex As Integer, Cancel As Integer)
Dim strSort As String
Dim Col As TrueOleDBList80.Column
' Loop through GroupColumns collection and construct
' the sort string for the Sort property of the Recordset
For Each Col In TDBList1.GroupColumns
If strSort <> vbNullString Then
strSort = strSort & ", "
End If
strSort = strSort & "[" & Col.DataField & "]"
Next Col
TDBList1.HoldFields
Adodc1.Recordset.Sort = strSort
End Sub
|
|
Run the program and observe the following:
Select the Country column and drag its header to the column group area as in the following picture.
Release the mouse button and note the change in the list's appearance. The rows are now sorted by the Country field. In addition, the list will automatically group the same values in the grouped column into one cell.
Select the Last column and drag its header to the grouping area.
The list's display should change as in the following picture:
Note that this time the data is sorted by both columns. Primary sort is done on Country and secondary sort on Last field. This order corresponds to the following SQL statement:
| Example Title |
Copy Code
|
|---|---|
SELECT * FROM Composer ORDER BY Country, Last |
|
Experiment with different columns.
Congratulations, you have successfully completed all 23 tutorials!