ColPosition Property

Moves a given column to a new position.

Syntax

[form!]vsFlexGrid.ColPosition(Col As Long)[ = NewPosition As Long ]

Remarks

The Col and NewPosition parameters must be valid column indices (in the range 0 to Cols - 1), or an error will be generated.

When a column or row is moved with ColPosition or RowPosition, all formatting information moves with it, including width, height, alignment, colors, fonts, and so on. To move text only, use the Clip property instead.

For example, the following code shows how you can insert a new column at an arbitrary position on the grid:

    Sub InsertCol(pos%)

        fg.Cols = fg.Cols + 1

        fg.ColPosition(fg.Cols - 1) = pos

        fg.TextMatrix(0, pos) = "New " & fg.Cols

    End Sub

The ColPosition property gives you programmatic control over the column order. You may also use the ExplorerBar property to allow users to move columns with the mouse.

Data Type

Long

See Also

VSFlexGrid Control