Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repositioning in a grid 1

Status
Not open for further replies.

kpnagle

MIS
Mar 31, 2001
13
US
I have a grid that displays data from a table. The user has the option of looking at various subsets of the data by selecting from a couple of combo boxes. How do I reposition the active row so that the data that is displayed starts in the first visible row of the grid. Right now the data is usually somewhere in the middle of the screen which forces the users to scroll down to see more of the items.
 
I don't know what you mean

Whether you want to display the top level record visible in the grid. If yes, Please put GO TOP after setting the Grids recordsource property or refreshing the grid.


gchandrujs[sunshine]
 
Clarification: Let's say we have 10 categories of products that the user can look at. They select category 7 so the
record pointer is repositioned to the first item in category seven. I don't have a problem locating category seven or putting the cursor on the first item, I just want the items to start filling in from the top of the grid.

After they click the button the data in the grid appears as follows:

category 6 item 1
category 6 item 2
category 6 item 3
category 6 item 4
category 7 item 1 <- This should appear at the top
category 7 item 2
category 7 item 3
category 7 item 4

I would like the grid to look like this:

category 7 item 1
category 7 item 2
category 7 item 3
category 7 item 4
category 7 item 5
category 7 item 6
category 7 item 7
category 7 item 8

 
If your grid is a fixed size, you could do it this way:
[tt]
* AFTER grid is refreshed:
FOR i=1 to 4
thisform.grid1.DoScroll(0)
ENDFOR
[/tt]
This will cause the grid to scroll up 4 rows. Adjust as needed.

This is actually the OPPOSITE of what I implement it for. I populate a grid with an SQL statement, LOCATE FOR the current value, then set the grid's RECORDSOURCE to the cursor. This always puts the current record at the top, so I use DOSCROLL() to move it to the middle. My users HAVE to know if there are records above the current one, and they can't be trusted to &quot;notice&quot; that the scroll bar shows them this.

Hope that helps,

Ian
 
Whoops...my bad. That should have been:
[tt]
thisform.grid1.DoScroll(1)
[/tt]
Ian
 
Thank you. I guess I was on the right track. I had tried to use the doscroll method to reposition as you suggest by using the .relativerow property to tell me how much to go up or down, but it was so this didn't work since .relativerow evalutated to zero.
 
The doscroll method did the trick. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top