?
Solved

Select all rows in DBGrid

Posted on 2001-06-18
1
Medium Priority
?
726 Views
Last Modified: 2010-04-06
Hi Experts,

I'm using a DBGrid in an application, with the Multiselect and Rowselect properties set to true. So users can select multiple rows with the Ctrl key pressed.

Now I want to place a "Select all" button on my form as a special service to the users. When a user clicks that button all the rows in the DBGrid should be selected.

Is this possible?

Thanks,
JDN
0
Comment
Question by:JDN
1 Comment
 
LVL 3

Accepted Solution

by:
VSF earned 150 total points
ID: 6203991
Here we go...
Hope this procedure helps!!!

VSF
www.enge.cjb.net
www.victory.hpg.com.br

SELECT ALL ROWS IN A DBGRID
You will need to set the multiselect property to true.

(Expand the options property to find multiselect.)

procedure TForm1.SelectAll;
begin
 with dbgrid1.DataSource.Dataset do
   begin
     if (BOF and EOF) then Exit;
     DisableControls;
     try
       First;
       while not EOF do
       begin
         dbgrid1.SelectedRows.CurrentRowSelected := True;
         Next;
       end;
     finally
       EnableControls;
     end;
end;
   end;  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
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…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

839 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