TextMatrixfunction
Returns or sets the text contents of an arbitrary cell.
Syntax
FUNCTION TextMatrix (BYVAL nRow AS LONG, BYVAL nCol AS LONG) AS DWSTRING
FUNCTION TextMatrix (BYVAL nRow AS LONG, BYVAL nCol AS LONG, BYREF wszText AS WSTRING) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
nRow | The zero-based index of the row. | |
nCol | The zero-based index of the column. | |
wszText | The text to set. |
Description
Returns or sets the text contents of an arbitrary cell.
Remarks
Unlike the Text property, which only interacts with the active cell (defined by the Row and Col properties), TextMatrix allows you to target any cell directly using coordinates.
It is significantly faster than using Row, Col, and then Text because it avoids the overhead of moving the user's focus and redrawing the selection highlight.
You can update data in the background without affecting what the user has currently highlighted.
It works for all cells, including fixed (header) rows and columns, making it the standard tool for setting column headers at runtime.
Examples
' To set a cell value: grid.TextMatrix(row, col, string)
' To retrieve a cell value: variable = grid.TextMatrix(row, col)
' Setting a header label in the first fixed row grid.TextMatrix(0, 1) = "Customer Name"
' Setting data in a specific data row grid.TextMatrix(1, 1) = "John Smith"
' Retrieving data for a calculation Dim price As Double price = Val(grid.TextMatrix(5, 2))
Reference
- Documented in Windows/Windows GUI/MSHFlexGrid Class.md
- Topic: Microsoft Hierarchical Grid