Recent

Author Topic: [SOLVED] TDrawGrid - multiselection with CTRL?  (Read 12213 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1057
[SOLVED] TDrawGrid - multiselection with CTRL?
« on: January 02, 2015, 11:18:09 pm »
Hi,

I'm playing with draw grid options. There is range select with SHIFT but can I select custom rows with CTRL like in TListView multi select property?

Regards
« Last Edit: January 03, 2015, 02:16:23 pm by Dibo »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TDrawGrid - multiselection with CTRL?
« Reply #1 on: January 03, 2015, 04:21:57 am »
Based on a quick search for ssCtrl in lcl\grids.pas, the answer is no.  :(

wp

  • Hero Member
  • *****
  • Posts: 13324
Re: TDrawGrid - multiselection with CTRL?
« Reply #2 on: January 03, 2015, 11:42:55 am »
Yes you can...

In trunk, we recently added a RangeSelectMode property which, if set to rsmMulti, allows to select several cell blocks by by means of the ctrl key - see the screenshot in http://bugs.freepascal.org/view.php?id=27000. If option goRowSelect is set this works also with entire rows.

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: TDrawGrid - multiselection with CTRL?
« Reply #3 on: January 03, 2015, 12:51:16 pm »
Great news wp . Do you know when it will be in stable version?

wp

  • Hero Member
  • *****
  • Posts: 13324
Re: TDrawGrid - multiselection with CTRL?
« Reply #4 on: January 03, 2015, 01:12:33 pm »
Target version in bugtracker is 1.2.8. Since 1.4 is scheduled for this year I guess 1.28 will be out pretty soon.

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: TDrawGrid - multiselection with CTRL?
« Reply #5 on: January 03, 2015, 02:16:03 pm »
Indeed, tried lazarus from SVN and grid has multi selection. Great. Problem solved

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #6 on: September 25, 2015, 02:05:23 pm »
Hi, range selctmode rsmulti is not working as expected by me.
Code: [Select]
if StringGrid1.SelectedRangeCount >= 1 then
        begin
          for i:=1 to StringGrid1.SelectedRangeCount do
           begin
             ShowMessage(IntToStr(StringGrid1.SelectedRange[i].TopLeft.X)+':'+IntToStr(StringGrid1.SelectedRange[i].TopLeft.Y)+' - '+IntToStr(StringGrid1.SelectedRange[i].BottomRight.X)+':'+IntToStr(StringGrid1.SelectedRange[i].BottomRight.Y));
           end;
        end;
It shows the same range for every iteration.
Is the code wrong?
Thx.

wp

  • Hero Member
  • *****
  • Posts: 13324
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #7 on: September 25, 2015, 03:23:24 pm »
Quote
Is the code wrong?
No idea, the code you posted seems to be ok, but I don't know what else you are doing. I just rechecked with Win 7, Laz 1.5, fpc 2.6.4, and the multiselection is doing fine -- see attached demo: Run, click any cell to create the first selection as shown in the memo at the bottom, CTRL-click at another cell to create the second selection etc. SHIFT-click extends the current selection. The selection boundaries are displayed in the memo at the bottom.

What is your operating system?
« Last Edit: September 25, 2015, 03:56:35 pm by wp »

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #8 on: September 28, 2015, 10:49:38 am »
Thank you very much for this example.
My problem is that if you click multiple times the same cell it will add a new selection and does not merge selections.
Is this the intended mode? Please see the attached screenshot.
Thank you.

wp

  • Hero Member
  • *****
  • Posts: 13324
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #9 on: September 28, 2015, 11:02:49 am »
I think this is related to the bug that I reported some time ago (http://bugs.freepascal.org/view.php?id=27437).

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #10 on: September 28, 2015, 11:31:42 am »
I think this is related to the bug that I reported some time ago (http://bugs.freepascal.org/view.php?id=27437).
Thank you.

wp

  • Hero Member
  • *****
  • Posts: 13324
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #11 on: September 28, 2015, 10:49:15 pm »
The bug that I mentioned above is fixed in trunk now. But as I see it does not fix the behavior that you mentioned earlier today. Thinking about your observation that multiple clicks onto the same cells are added as new selections I am a bit uncertain if this a bug or if this could be used as a feature in some cases. What exactly is disturbing you (except for the few bytes of wasted memory)?

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #12 on: September 29, 2015, 10:13:25 am »
The bug that I mentioned above is fixed in trunk now. But as I see it does not fix the behavior that you mentioned earlier today. Thinking about your observation that multiple clicks onto the same cells are added as new selections I am a bit uncertain if this a bug or if this could be used as a feature in some cases. What exactly is disturbing you (except for the few bytes of wasted memory)?
I want to add a copy (CTRL-C) function to the string grid which add to clipboard all (not only the last one as implemented) selections...but only once.

wp

  • Hero Member
  • *****
  • Posts: 13324
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #13 on: September 29, 2015, 11:54:38 am »
But again: what is the problem (except for waising a few bytes of memory) that the same cell is in the clipboard multiple times?

mdalacu

  • Full Member
  • ***
  • Posts: 234
    • dmSimpleApps
Re: [SOLVED] TDrawGrid - multiselection with CTRL?
« Reply #14 on: September 29, 2015, 12:03:23 pm »
But again: what is the problem (except for waising a few bytes of memory) that the same cell is in the clipboard multiple times?
It is harder for me to implement an algorithm to merge selections (regions) and then copy them to clipboard. The current implementation of TStringGrid.CopyToClipboard(True) puts in the clipboard only the first region selected, disregarding that you have multiple regions selected in the grid. Maybe the is a bug too and i dont't have to do anything just to wait for it to be solved....the documentation  is sketchy on rsmmultiple....

 

TinyPortal © 2005-2018