Recent

Author Topic: Select several row with Shift key in dbgrid  (Read 4007 times)

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Select several row with Shift key in dbgrid
« on: May 23, 2016, 04:25:16 pm »
Hi my friends  :) , how i can Select several row with Shift key in dbgrid ?

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Select several row with Shift key in dbgrid
« Reply #1 on: May 23, 2016, 05:08:08 pm »
set property dgMultiSelect to true
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Select several row with Shift key in dbgrid
« Reply #2 on: May 25, 2016, 03:52:00 am »
Hi, I tried activating dgMultiSelect but nothing, only key "CTRL" works.  :(

balazsszekely

  • Guest
Re: Select several row with Shift key in dbgrid
« Reply #3 on: May 25, 2016, 07:17:21 am »
@Pascalito100
Is not working because dgRangeSelect is not implemented.

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Select several row with Shift key in dbgrid
« Reply #4 on: May 25, 2016, 06:53:48 pm »
then as I can select multiple rows with few clicks  :(
because with "CTRL" I can only one to one.

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: Select several row with Shift key in dbgrid
« Reply #5 on: May 26, 2016, 01:06:48 am »
for now this works for me  :)

Code: Pascal  [Select][+][-]
  1. uses
  2.   LCLIntf,
  3.   Windows;
  4.  
  5. //.....
  6.  
  7. var
  8.    firstpoint, thispoint: tpoint;
  9.    thisfield : string;
  10.  
  11. //.....
  12.  
  13. procedure TForm1.DBGrid1CellClick(Column: TColumn);
  14. begin
  15.        if (dgmultiselect in dbgrid1.options) then
  16.         if getkeystate(vk_shift) < short(0) then begin
  17.            getcursorpos(thispoint);
  18.            while not SQLQuery1.eof and not SQLQuery1.bof and
  19.                  not (dbgrid1.datasource.dataset.fields[0].asstring =
  20.                        thisfield) do begin
  21.                  if thispoint.y > firstpoint.y then
  22.                     SQLQuery1.prior
  23.                  else
  24.                     SQLQuery1.next;
  25.                  dbgrid1.selectedrows.currentrowselected := true;
  26.            end;
  27.         end;
  28.      getcursorpos(firstpoint);
  29.      thisfield := dbgrid1.datasource.dataset.fields[0].asstring;
  30. end;

but I would have another suggestion  ::) ::)

 

TinyPortal © 2005-2018