Recent

Author Topic: Questions about selecting rows in StringGrids  (Read 7158 times)

CM630

  • Hero Member
  • *****
  • Posts: 1704
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Questions about selecting rows in StringGrids
« on: October 08, 2012, 02:59:24 pm »
First I was wondering how to find which are the selected rows in a TStringGrid.
Selection.top and Selection.bottom obviously would not do, because if rows №1,2 and 5 are selected, top would be 1 and bottom would be 5, and I would have the fake results 3 and 4 into the array.
Then I found out that I cannot select rows №1,2 and 5- holding the shift key allows me to select top to bottom (or vice versa), but holding the Control key and clicking on a row (cell) occurs to clean the previously selected rows.
How can I solve this situation?
« Last Edit: October 08, 2012, 03:01:20 pm by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1704
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Questions about selecting rows in StringGrids
« Reply #1 on: October 10, 2012, 07:32:09 am »
67 people read the topic and no answer.
Shall I understand that in Lazarus selecting arbitrary rows in a stringgrid is impossible?
Any proposal for a replacement of stringgrid is welcome.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Questions about selecting rows in StringGrids
« Reply #2 on: October 10, 2012, 07:44:20 am »
What does the wiki article on grids say?
Is there, say, a MultiSelect property?

What does the Delphi stringgrid documentation say about this?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Questions about selecting rows in StringGrids
« Reply #3 on: October 10, 2012, 12:33:45 pm »
If component can draw the selected rows with different colors, it knows where they are. Can you do something similar to how TListBox handles multiselection? I don't remember exactly, maybe a Selected[] array. If there is a function that tells you if 1 row is selected, then you can go through them all, given the top and bottom to limit the search range.

CM630

  • Hero Member
  • *****
  • Posts: 1704
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Questions about selecting rows in StringGrids
« Reply #4 on: October 10, 2012, 02:38:36 pm »
This idea might do. Background color of cells (rows) can be set (quite weirdly, though), so colouring a row OnClick,etc. should not be too hard to do.
I will check how TListBox handles multi selection.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Questions about selecting rows in StringGrids
« Reply #5 on: October 10, 2012, 05:03:23 pm »
I didn't mean you should manually color them. When you select multiple cells, you can see they are selected? With standard OS colors, it means the default drawing of the component knows what is selected.

CM630

  • Hero Member
  • *****
  • Posts: 1704
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Questions about selecting rows in StringGrids
« Reply #6 on: October 12, 2012, 07:34:04 am »
In fact in StringGrid multiple rows cannot be selected freely (at least I found now way how to do it).
Only sequential rows can be selected (i.e. I can select rows №№2;3;4;5 but I cannot select 1;3;19; 21).
So so far colouring manually seems the only option.
Double Commander uses some better control, I'll try to check what it is.
« Last Edit: October 12, 2012, 07:36:07 am by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018