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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Position... Help please

Status
Not open for further replies.

KEJinSC

Programmer
Sep 12, 2002
7
US
I need some help with something. I am trying to use a DataGrid to display the contents of an ado recordset. I would like to be able to position to a particular record within the grid programmatically. I don't see a way to do this. In other words, if I have 100 records in my recordset and the grid is scrolled all the way to the bottom so that the 100th record is shown, how can I cause the grid to reposition to the 1st, 50th, or any other particular record so that it can be seen. I don't want the user to have to do anything at all to invoke this. I want to reposition to the beginning after populating the grid and I also want to search through the recordset and show the record that has been found.

Thanks,
Keith Johnson
 
Is there a listindex property? or maybe a row and column property - I think there is one in the msflexgrid.

Hope this helps...
 
I can make a row the current row, but it doesn't appear to refresh the display to make it visible. Even when using the refresh method.
 
You navigate through a DataGrid by navigating the recordset that it is bound to:

If the grid is at the 100th record, then so is the recordset.
rs.Movefirst will move the grid to the first record.
rs.MoveNext will also move the grid position.

Return to a certain position using a bookmark:

Dim bkm As Variant
rs.MoveFirst
bkm = DataGrid1.Bookmark
rs.MoveLast
Now the grid will show the last record.
rs.Bookmark = bkm

Now the grid will move back to the first record...the record identical to the bookmark.

[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 

>>"...the record identical to the bookmark"

Before someone jumps on me:

....the record bookmark identical to the saved grid bookmark

Info: The current record in the grid has the same bookmark as the corresponding record in the recordset.

[/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top