Grid Object Methods and Properties

Question:

I have opened a table as a grid object. I want to go to a desired column (say 34) and the table has 62 fields. Currently only columns 1 through 10 are visible.

How can I accomplish this?

Answer:

There is one method and two properties of grid objects that apply to what you are trying to accomplish: ActivateCell, ActiveRow, and ActiveColumn. Grids have a method called ActivateCell, where you can pass a row number and a column number to set focus to a particular cell in the grid, whether it is visible or not. ActiveRow is the current row in the grid and ActiveColumn is the current column in the grid.

So if you wanted to activate the 34th field (column) in the current row of the grid, you would execute the following:

thisform.oGrid.ActivateCell(thisform.oGrid.ActiveRow,34)

The tricky part about using ActiveRow and ActiveColumn is that they only have a value when the grid has focus; otherwise they are 0. Therefore, you need to add the following line before the ActivateCell call:

thisform.oGrid.SetFocus()

This gives the grid focus and therefore shows correct values in the ActiveRow and ActiveColumn properties.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: