This tutorial demonstrates how you can bind the BeeGrid control to the MS ADODC data control.
In addition, you will learn how to sort and group data.
1. Simple Bound
- From the Visual Basic« File menu, choose New Project.
- Press Ctrl+T or select Components from Project menu.
Check the Stinga BeeGrid Control 1.0 (OLEDB) and the Microsoft ADO Data Control 6.0 checkboxes.
- Place a BeeGrid control and an ADO Data control on the form.
- Create an ADODB connection.
- Right-click on the ADO Data control and select ADODC properties.
- Click the Build... button to open the Data link properties window.
- Select Microsoft Jet 3.51 OLE DB Provider .
- Click the Next button or click the Connection tab.
- Enter the path of the NorthWind database (usually 'C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB').
- Click the OK button to close the Data link properties window.
- In the ADODC properties dialog select the RecordSource tab.
- Set the Command Type property to 2 - adCmdTable.
- Set the RecordSource property to table Catalog.
- Set the DataMode property of
the SGGrid1 control to 0 - sgBound.
- Set the DataSource property of
the SGGrid1 control to Adodc1.
Note that Picture field is automatically recognized and
displayed as an image.
Show Me
2. Sorting And Merging Cells
- Set the ColumnClickSort property to True.
The column-click-sort does not work if data caching is not enabled, so set the
CacheAllRecords property to True.
- Right-click on the SGGrid1 and select Properties... to display the Property Pages dialog. Select the Columns Tab and click the
Retrieve fields button to populate the grid with fields. Expand the Description column and set the property MergeCells to 1 - sgMergeFree.
The following line sets the MergeCells from the code:
SGGrid1.Columns("Description").MergeCells = sgMergeFree
Note: if you change columns properties using the Property Pages set the AutoFields
property to False.
Show Me
3. PreviewPane
- Set the PreviewPaneType property to sgPreviewPaneDefault.
- Set the PreviewPanePosition property to sgPreviewPaneBottom.
- Use the Picture column for the PreviewPaneColumn property.
- Enlarge the PreviewPane using the PreviewPaneSize property.
- Center picture on the PreviewPane using the "PreviewPane" style. You can
do it from the code:
SGGrid1.Styles("PreviewPane").PictureAlignment = sgPicAlignCenterCenter
- Hide the Picture column using the Property Pages or the following code:
SGGrid1.Columns("Picture").Hidden = True
Show Me
4. Groups
- Add a group to the Groups collection. You can do it from the code:
SGGrid1.Groups.Add "CategoryName", sgSortAscending, sgSortTypeString, False, True
- Hide the CategoryName column from the Property Pages or from the code:
SGGrid1.Columns("CategoryName").Hidden = True
Show Me
5. Frozen columns
- You can define style for frozen columns using the "Frozen" style.
For example, the code below changes the background of frozen columns:
SGGrid1.Styles("Frozen").BackColor = &HDDFFFF
- Set the property of the columns you want to freeze to True:
SGGrid1.Columns("ProductName").Frozen = True
Show Me