AddColumn, DeleteColumn

These methods let you add and remove columns from a grid on the fly. They're more powerful than simply changing ColumnCount because they let you put the new column wherever you want it.

Usage

grdGrid.AddColumn( nColumnPosition )
grdGrid.DeleteColumn( [ nColumnPosition ] )
The column position passed to these methods refers to ColumnOrder (the visible position), not position in the Columns collection (which is based on creation order). When you DeleteColumn, the columns after that one move up in the Columns collection. Added columns always go at the end of the collection, regardless of their ColumnOrder.

In Help for VFP 5 and before, it says DeleteColumn removes the active column if you don't pass the parameter. T'ain't so. If you omit the nColumnPosition parameter, DeleteColumn tosses out the last column in ColumnOrder regardless of ActiveColumn. Fortunately, this was fixed in VFP 6.


Example

This.DeleteColumn(2)            && Remove second column
Thisform.grdMyGrid.AddColumn(3) && Add a column, make it third

See Also

AddObject, ColumnCount, ColumnOrder, Columns, RemoveObject


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .