Article ID: 137963
Article Last Modified on 8/26/1999
LPARAMETERS nColIndex
* LPARAMETERS statement required and inserted by Visual FoxPro
* Check to see if you're on column one
IF nColIndex = 1
* Change the active cell
WITH This
.ActivateCell(.RelativeRow, 2)
ENDWITH
ENDIF
NOTE: This example makes use of the RelativeRow property. Do not use the
ActiveRow property; it will not work properly. Note that the ActiveCell
method assigns the focus to column two even if column two is disabled or
the current control in column two is disabled.
LPARAMETERS nColIndex
* LPARAMETERS statement required and inserted by Visual FoxPro
LOCAL iLoop, iMax, lFocusSet
WITH This && Grid
* Initialize Loop Variables
iMax = .ColumnCount
iLoop = nColIndex + 1
* Check if current column is valid
WITH .Columns(nColIndex)
* Column is valid only if the Column's Enabled Property is True
* and the CurrentControl's Enabled Property is True
* Note: The EVAL function (cf. EVALUATE() online help) is used as
* as an alternative to macro substitution for accessing the
* column's current control
lFocusSet=.Enabled .AND. EVAL("." + .CurrentControl + ".Enabled")
ENDWITH
* Start at next column (to the right) and cycle through all columns
* until a valid column is reached or loop returns to current column
* Note: If the current column is valid, lFocusSet = true and this
* loop is skipped
DO WHILE iLoop # nColIndex .AND. .NOT. lFocusSet
* Wrap to first column if necessary
IF iLoop > iMax
iLoop = 1
ELSE
WITH .Columns(iLoop)
* If this column is Valid (same criteria as above)
IF .Enabled .AND. EVAL("." + .CurrentControl + ".Enabled" )
* Set focus to column and end loop
.SetFocus
lFocusSet = .T.
ENDIF
ENDWITH
* Advance to next column
iLoop = iLoop + 1
ENDIF
ENDDO
ENDWITH
NOTE: This example does not take into account columns or controls within
columns that have a When event that returns False.
Additional query words: VFoxWin
Keywords: KB137963