Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual FoxPro
Expertise: Beginner
Jan 21, 2000

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.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date