ColHeaderCaptionfunction
Specifies the caption to display in the header of the specified column and band.
Syntax
FUNCTION ColHeaderCaption (BYVAL BandNumber AS LONG, BYVAL BandColIdx AS LONG) AS DWSTRING
FUNCTION ColHeaderCaption (BYVAL BandNumber AS LONG, BYVAL BandColIdx AS LONG, BYREF wszCaption AS WSTRING) AS HRESULT
FUNCTION ColHeaderCaption (BYVAL BandColIdx AS LONG) AS DWSTRING
FUNCTION ColHeaderCaption (BYVAL BandColIdx AS LONG, BYREF wszCaption AS WSTRING) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
BandNumber | A zero‑based index identifying the band that contains the specified column to set the caption. If the band number is omited, band 0 is assumed. | |
BandColIdx | The index of the column within that band. | |
wszCaption | The caption to set. |
Description
Specifies the caption to display in the header of the specified column and band.
Remarks
Overwriting field names: When bound to a database, the grid defaults to using database field names as headers. ColHeaderCaption overwrites these field names with your custom text.
Redundancy issues: Sometimes setting ColHeader to flexColHeaderOn while using ColHeaderCaption can result in two headers (the custom one and the original database field name). You may need to adjust FixedRows or the ColHeader property to hide the unwanted row.
Read-only situations: In some specific configurations or older versions, these properties may appear as read-only if the data source is not properly initialized or if certain Access database drivers are used.
Alternative: For unbound grids, developers often simply use the TextMatrix property to set header text at Row 0: grid.TextMatrix(0, 1, "Caption").
Examples
grid.ColHeaderCaption(0, 0, "Part Code") grid.ColHeaderCaption(0, 1, "Job Number") grid.ColHeaderCaption(0, 2, "Scrap") grid.ColHeaderCaption(0, 3, "Reason")
To set the header for the first four columns of the first band (Band 0):
Reference
- Documented in Windows/Windows GUI/MSHFlexGrid Class.md
- Topic: Microsoft Hierarchical Grid