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

finding row number in dbgrid

Status
Not open for further replies.

delfy

MIS
Feb 8, 2005
96
JM
how can i do this using delphi 6

i hava a dbgrid with multi select enabled

i use this line to locate the selected rows GotoBookmark(pointer(DBGrid1.SelectedRows.Items));

but how can i know the row of the grid i am currently on after making a call to GotoBookmark while going through a loop?
 
Check out thwe FAQ area

How do I quickly find data in a dbGrid?
faq102-4557

Steven van Els
SAvanEls@cq-link.sr
 
i need to be able to know the row numbers of all the selected rows on the grid
 
If you use Query to provide records for a DBGrid, then you can use Query.RecordCount property.
 
FYI - RecordCount only works with some database engines though. We use an AS400 as the backend to my queries and the RecordCount is always -1. I either have to run the query twice (once as a SELECT COUNT, once with the fields) if I need the exact number of records or alternately loop through the record set and increment an integer counter.

Leslie
 
ok well... this i figured out where ever i am in the dataset thats where i am on the DBgrid and the converse is true. So i just maintain a counter and loop through the dataset, testing for selection on my DBgrid. that way i can get the record number of any selection made on my DBgrid. RecordCount gives the total number of records in the DataSet.

using GotoBookmark and DataSet.RecNo to determine the number of the current record doesn't seem to work??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top