Page 1 of 1

CRDBGrid SelectAll

Posted: Mon 26 May 2008 09:49
by deca
Hi,

I use the CRDBGrid in many of our application, and I'm very happy with them.

Theres just one problem with selecting rows.

When you want to select all records there is no method for it.

So I handle "CTRL+A" to execute following code:

Code: Select all

    MyQry.First;
    while not MyQry.Eof do
    begin
      Grid.SelectedRows.CurrentRowSelected := true;
      MyQry.Next;
    end;
If you have only a small count of rows this work pretty good, but if you have greater tables, as it is in the most of our projects, the method case to scroll down the complete table and handle each row.

So in a normal project of us I counted such a selectall of 20sec for just about 7000 rows, wich is definitely to long.

May you can me provide a better solution or integrate a selectall method in the CRDBGrid?

I'm using:
Delphi 7.0 with MyDac 5.50.0.34

Best regards,
Karsten Hansske

Posted: Tue 27 May 2008 09:06
by Dimon
In order to solve this problem, you can use the following code:

Code: Select all

    Grid.Hide;
    try
      MyQry.First; 
      while not MyQry.Eof do 
      begin 
          Grid.SelectedRows.CurrentRowSelected := true; 
          MyQry.Next; 
      end; 
    finally
      Grid.Show;
    end;

Posted: Tue 27 May 2008 09:15
by deca
But this is exactly what we are doing. This is working with a small count of records. But with greater tables it's really slow. So we need another kind of solution. Do you have any other?

Posted: Wed 28 May 2008 09:44
by Dimon
deca wrote:But this is exactly what we are doing.
Note, I use the Grid.Hide and Grid.Show methods, which speed up execution. It should work quickly.

Posted: Fri 25 Jul 2008 14:30
by deca
Yes, the speed is faster while hiding the grid. But there is no other function to select directly all records?