FormatStringproperty
Sets the column widths, alignments, fixed row text, and fixed column text of the MSHFlexGrid.
Syntax
PROPERTY FormatString () AS DWSTRING
PROPERTY FormatString (BYREF wszStr AS WSTRING)
Parameters
| Name | Description | |
|---|---|---|
wszStr | The string to set. |
Description
Returns or sets the column widths, alignments, fixed row text, and fixed column text of the grid.
Remarks
The FormatString property contains segments separated by pipe characters (|). The text between pipes defines a column and may also contain special alignment characters. These characters align the entire column to the left (<), center (^), or right (>). In addition, the text is assigned to row zero by default, and the text width defines the width of each column.
The FormatString property may contain a semicolon (;). This causes the remainder of the string to be interpreted as row heading and row width information. In addition, the text is assigned to column zero by default, and the longest string defines the width of column zero.
The MSHFlexGrid creates additional rows and columns to accommodate all fields defined by the FormatString. Additional rows and columns are not deleted if only a few fields are specified. To remove additional rows and columns, set the Rows and Cols properties.
The MSHFlexGrid automatically sizes columns based on the length of the strings provided in the FormatString. If you add extra spaces (e.g., " Name "), the column will be wider.
The labels defined in this property are automatically placed in the Fixed areas (Row 0 and Column 0).
Assigning a value to FormatString resets any previous column count and header text, making it a quick way to "re-skin" a grid for a different data view.
Examples
' < = Left Align, ^ = Center, > = Right Align grid.FormatString = "<ID |^Name |>Date "
' Sets 3 column headers and 2 row headers grid.FormatString = "Product | Price | Stock ; Item 1 | Item 2"
Reference
- Documented in Windows/Windows GUI/MSHFlexGrid Class.md
- Topic: Microsoft Hierarchical Grid