Solved

Highlighted DBGrid entries, getting first & last...

Posted on 1997-11-05
2
169 Views
Last Modified: 2010-04-04
Hi!

I have a DBGrid attached to a table with about 630,000 entries in the table. The DBGrid is set to multiselect so the user can highlight (tag) any number of entries that interest them.

I can use a loop, starting from the first record and scanning all the entries until I come upon a DBGrid.SelectedRows.CurrentRowSelected to determine if a row is selected or not, but certainly there must be a better way to determine the first and last entries the user selected and just scan the records in between to find out which ones are selected as opposed to scanning the entire table!

The DBGrid component uses TBookmarks to keep track of the records the user selected but the documentation is horrible about TBookmarks. Is there a BookmarkFirst or BookmarkLast something or another to remedy this situation.

I'd appreciate hearing some creative solutions to this seemingly simple problem : )

Pegasus
My question is this.

0
Comment
Question by:Pegasus100397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 160 total points
ID: 1349565
1. See explanation in the file manuals.txt.
2. example:

var I, J: Integer;

with DBGrid.SelectedRows, Table1 do //the records from the grid
                                      belong to Table1
for I:=0 to Count-1 do //do some actions only on the selected                          records
begin
  Find(Items[I],J);
  Bookmark:=items[I];
  Edit;
  //do something with the current selected record
  Post;
end;

//to find the last selected record do the following:
with DBGrid.SelectedRows, Table1 do
begin
  Find(Items[Count-1],J);
  Bookmark:=items[Count-1];
  Edit;
  //do something with the last selected record
  Post;
end;
0
 
LVL 3

Author Comment

by:Pegasus100397
ID: 1349566
Ronit,

Thanks for the answer! Solved my problem in 3 lines of code!

Talk about obscure documentation! I've never looked (or known  of Manuals.TXT) but found gobs of stuff in there pertaining to questions I've had. Thanks for turning me on to it. (I'll never say that REAL programmers never read the documentation again!).

Again, thanks for the answer!
Pegasus
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question