Help Center

ColPositionproperty

Sets the position of an MSHFlexGrid column, allowing you to move columns to specific positions.

Windowspropertydoc-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

PROPERTY ColPosition (BYVAL Index AS LONG, BYVAL newPos AS LONG)

Parameters

NameDescription
IndexThe current zero-based index of the column you want to move.
newPosThe target zero-based index where the column should be placed.
BandNumberOptional. A Long value that specifies the band that contains the column.

Description

Sets the position of an MSHFlexGrid column, allowing you to move columns to specific positions.

Remarks

Unlike ColPos (which returns a pixel/twip coordinate), ColPosition is used to move a column from its current index to a new index location.

When a column is moved, all other columns between the old and new positions automatically shift to fill the gap.

This property moves the entire column including its data, ColWidth, and individual cell formatting.

This property is primarily intended for grids in unbound mode. If the grid is bound to a data source, the order is typically governed by the fields in the underlying recordset; manually moving columns may be overwritten upon a data refresh.

Examples

' Moves column 2 to the far left grid.ColPosition(2) = 0

' Moving column 0 to position 1 effectively swaps the two grid.ColPosition(0) = 1

Reference