Help Center

DataSourceproperty

Returns or sets the data source.

Windowspropertydoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

PROPERTY DataSource () AS Afx_IDataSource PTR
PROPERTY DataSource (BYVAL Data_Source AS Afx_IDataSource PTR)

Parameters

NameDescription
Data_SourceThe data source, such an ADODC (Microsoft ADO Data Control) or a live ADODB.Recordset.

Description

Returns or sets the data source.

Remarks

The DataSource property is used at runtime to bind the grid to a data source object, such as an ADODC (Microsoft ADO Data Control) or a live ADODB Recordset.

A key distinction of the MSHFlexGrid (versus the standard MSFlexGrid) is its full compatibility with ADO and its ability to handle hierarchical recordsets.

When bound to a recordset created with the MSDataShape provider (using the SHAPE command), the grid automatically creates "bands" to represent nested parent-child relationships.

If the data source contains multiple members or tables, the DataMember property is often used in conjunction with DataSource to specify which particular set of data to display.

Even when bound via DataSource, the MSHFlexGrid remains a display-only control. It does not natively support direct in-cell editing; updates must be handled by overlaying controls or manually updating the underlying recordset.

Upon setting a new DataSource, the grid typically rebuilds its structure (columns and bands) to match the new data source.

A long-standing legacy behavior remains where the grid may only display up to 2,048 rows when bound, even if the data source contains more records. For larger datasets, developers often use the Clip property or manual population methods.

To ensure the grid reflects changes made to the data source at runtime, it may be necessary to call the Refresh method or re-set the DataSource property.

Reference