Help Center

DataFieldfunction

Returns the name of the field bound to the specified column in the specified band.

Windowsfunctiondoc-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

FUNCTION DataField (BYVAL BandNumber AS LONG, BYVAL BandColIdx AS LONG) AS DWSTRING

Parameters

NameDescription
BandNumberThe zero‑based index of the band that contains the column.
BandColIdxThe zero‑based index of the column within that band.

Description

Returns the name of the field bound to the specified column in the specified band.

Remarks

When the MSHFlexGrid is bound to a data source (such as an ADODC or a shaped Recordset), each column automatically receives a DataField value corresponding to the underlying field name in the Recordset.

In hierarchical datasets created with SQL SHAPE, each band corresponds to a different Recordset level. In this case, the “data field” for a band column may come from:

  • a field in the parent Recordset
  • a field in a child Recordset
  • an alias defined in the SHAPE command (e.g., AS Orders)

This makes DataField useful for inspecting how the grid mapped fields to bands.

Although you can retrieve the bound field name, the MSHFlexGrid is fundamentally a read‑only display control. To edit data, developers typically overlay a TextBox, ComboBox, or other input control on top of the active cell and manually write changes back to the underlying Recordset.

By default, the grid uses the DataField names as column headers. If you want a more user-friendly name (e.g., "Customer ID" instead of "cust_id"), it is best practice to use SQL Aliases in your connection string (e.g., SELECT cust_id AS [Customer ID]...) rather than changing captions at runtime, as re-binding the grid will reset headers to the raw field names.

Changing captions at runtime is possible, but any re‑binding of the grid will restore the original field names unless they were aliased in the query.

Reference