CellFontNameproperty
Returns or sets the name of the font for the current cell text.
Syntax
PROPERTY CellFontName () AS DWSTRING
PROPERTY CellFontName (BYREF wszFontName AS WSTRING)
Parameters
| Name | Description | |
|---|---|---|
wszFontName | The font name. |
Description
Returns or sets the typeface (font name) for the currently active cell or a selected range of cells.
Remarks
This property affects the cell(s) specified by the current Row and Col properties.
- Set single cell: grid.CellFontName = "Arial"
- Read value: strFont = grid.CellFontName
To change the font name for multiple cells simultaneously without a loop, you must utilize the FillStyle property:
Set grid.FillStyle = flexFillRepeat (Value 1). Select the range using the Row, Col, RowSel, and ColSel properties. Assign the new font: grid.CellFontName = "Verdana". Reset grid.FillStyle = flexFillSingle (Value 0) to avoid accidental global changes later.
It is common to use CellFontName to display symbols or distinct data types in specific columns: Changing the font name can change the width of the text. You may need to manually update the ColWidth to ensure the text remains fully visible and is not clipped.
Example
grid.Row = 2: grid.Col = 1 ' Change typeface for a specific cell grid.CellFontName = "Courier New" grid.CellFontSize = 10 grid.Text = "Fixed-Width Data"
Reference
- Documented in Windows/Windows GUI/MSHFlexGrid Class.md
- Topic: Microsoft Hierarchical Grid