Help Center

AddItemfunction

Adds a row to an MSHFlexGrid. This property doesn’t support named arguments.

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 AddItem (BYREF Item AS WSTRING, BYVAL Index AS LONG = -1) AS HRESULT

Parameters

NameDescription
ItemRequired. A string expression displayed in the newly added row. To add multiple strings (for multiple columns in the row), use the tab character to separate each string.
IndexOptional. A Long value indicating the position within the control. This position is where the new row is placed. For the first row, index=0. If index is omitted, the new row becomes the last row in the band.

Description

Adds a row to an MSHFlexGrid.

Remarks

You can quickly fill a row with multiple values using a single line of code:

Performance optimization: When adding a large number of rows (e.g., thousands), it is critical to set Redraw = False before starting the loop and Redraw = True after to prevent flickering and improve speed.

Unbound requirement: AddItem is typically used when the grid is not bound to a data source. If the grid is bound to a hierarchical Recordset, attempting to use AddItem may result in a runtime error, as the structure is managed by the data source.

Example

' Adds a row with "ID" in Col 0, "Name" in Col 1, and "Date" in Col 2 grid.AddItem "101" & CHR(9) & "John Doe" & CHR(9) & "2026-01-02"

Reference