ActivateCell

This method lets you change which cell has the focus in a grid.

Usage

grdGrid.ActivateCell( nGridRow, nGridColumn )
As the parameters indicate, this method operates the rows and columns of the grid control, not records. You can't use it to simply choose any record or field to gain focus. Parameters of (1,1) refer to the cell displayed in the upper left corner of the grid; parameters of (3, 2) send it to the third row down, second column that's displayed.

You can activate a cell in any column that's visible or to the right of the visible portion (if there are six columns, but only the first four are visible, you can pass 6 as nGridColumn). Rows work similarly; you can activate a cell in any row that's visible or below the visible portion. It will activate the cell, but you can't guarantee if the active column is the first or last column displayed, if it's somewhere in the middle, or even if it's displayed (if the cell is not in the viewing area, it is activated, but the display does not scroll to display it). You can't go backward from the visible portion of the grid. A negative number is ignored for either parameter, leaving you on the same cell.


To set focus to a particular record, consider instead setting the record pointer to it with GO, LOCATE or SEEK. To move to a particular column, you can also use its SetFocus method. (You can do so even if the grid was created with ColumnCount = –1. The columns exist anyway as Column1, Column2, etc.)

Example

* This fails to find the first visible field of the
* first record in the display:
Thisform.grdMyGrid.ActivateCell(1,1)
 
* To activate the very first column of the first record in 
* the table, try this:
LOCATE  && the better GO TOP
Thisform.grdMyGrid.Column1.SetFocus()

See Also

ActiveColumn, ActiveRow, Go, Grid, Locate, Seek, SetFocus


Back to Table of Contents

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