devxlogo

Grid Object Methods and Properties

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.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist