Help Center

Bandsfunction

Returns the total number of bands in an MSHFlexGrid. The MSHFlexGrid always has a minimum of one band. When the MSHFlexGrid is bound to a standard Recordset, the entire MSHFlexGrid is treated as one 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 Bands () AS LONG

Description

Returns the total number of bands in an MSHFlexGrid. The MSHFlexGrid always has a minimum of one band. When the MSHFlexGrid is bound to a standard Recordset, the entire MSHFlexGrid is treated as one band.

Remarks

Bands are the structural components used to display hierarchical or "parent-child" data relationships. MSHFlexGrid uses bands to organize multi-level data sets.

Each band represents one level of a hierarchical Recordset. For instance, "Band 0" typically displays parent records (e.g., Customers), while "Band 1" displays associated child records (e.g., Orders).

Bands are primarily a feature of bound mode. They are most commonly populated using ADO Data Shaping (the MSDataShape provider). In unbound mode, the hierarchical functionality of bands is largely unavailable.

The number of bands depends entirely on the structure of the bound Recordset (or Data Shape). Band 0 is always the top‑level (root) band. Subsequent bands follow the order in the shaped Recordset. Unbound grids always return 1.

  • Bands Property: Returns the total number of bands in the control.
  • BandLevel / BandColIndex: Used to identify the specific band or column index within a band for formatting.
  • BandDisplay: Determines if bands are displayed horizontally (stacked) or vertically.

You can customize the appearance of each band independently to distinguish between data levels:

Coloring: Properties such as BackColorBand, BackColorHeader, and BackColorIndent can be set specifically for a BandNumber.

Interaction: Users can often expand or collapse bands to manage complex data views.

Header customization: You can set unique captions for columns within each band via the control's property pages at design time or through specific runtime properties.

Example

grid.Bands ' Gets the number of bands

Reference