Solved

Highlighted DBGrid entries, getting first & last...

Posted on 1997-11-05
2
168 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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