ActiveColumn, ActiveRow

These grid properties tell you which column and row of a grid contain the focus. They're useful only when the grid has focus.

Usage

nCurrentColumn = grdGrid.ActiveColumn
nCurrentRow = grdGrid.ActiveRow
These properties return an absolute number measured from the first cell of the grid, regardless of what portion is visible now. ActiveColumn's value is based, however, on the visible order of the columns reflected by their ColumnOrder, not on the creation order that the Columns collection uses. What does this all mean? It means you'll never want to look at Columns[ActiveColumn], because it's meaningless.You can't change the active cell with these properties. Use the ActivateCell method instead (though it works with relative rows and columns, not the absolute ones of these properties).ActiveRow counts from the top of the grid. If you're looking at a table in natural, unfiltered order (SET ORDER TO 0 and SET DELETED OFF), ActiveRow is the same as RECNO(). As soon as you SET ORDER TO something or apply a filter, though, the two part company.

In the original release of VFP 7, under some very special circumstances, ActiveColumn can be set to 0 with the grid appearing to lose focus. It happens only when another form is run from the Valid method of a control in the grid. The problem is fixed in Service Pack 1.


Example

IF This.ActiveColumn = 3
  * Take an appropriate action
  WAIT WINDOW "Hey, we're in the third column"
ENDIF

See Also

ActivateCell, Column, Columns, Grid, RelativeColumn, RelativeRow


Back to Table of Contents

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