Select all rows in DBGrid

Posted on 2001-06-18
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?

Question by:JDN
1 Comment

Accepted Solution

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


You will need to set the multiselect property to true.

(Expand the options property to find multiselect.)

procedure TForm1.SelectAll;
 with dbgrid1.DataSource.Dataset do
     if (BOF and EOF) then Exit;
       while not EOF do
         dbgrid1.SelectedRows.CurrentRowSelected := True;

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 106
how to center only a line in richedit? 4 52
Reconfigure Delphi Install? 2 46
Find and Replace Stream with 0s 8 57
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 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

16 Experts available now in Live!

Get 1:1 Help Now