Solved

Highlighted DBGrid entries, getting first & last...

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now