Welcome, Guest
Username: Password: Remember me

How to allow the user to select multiple cells?

Posts 1 to 5 of 5
  • Timur T7253
  • Timur T7253's Avatar
  • OFFLINE
  • Gold User
  • Rank: 89
  • Points: 6
1 week 1 day ago #7822
How to allow the user to select multiple cells of a TStringGrid object?Additionally, is there a way to select multiple cells of TStringGrid object using some code?(but these cells should be seen in the gui as highlighted cells)

I am using C++ Builder 10.1
Last Edit: 1 week 1 day ago by Timur T7253.
Log in to reply.
  • Roger Cigol
  • Roger Cigol's Avatar
  • OFFLINE
  • Gold User
  • Rank: 33
  • Points: 85
  • Thanks 16
1 week 1 day ago #7828
Hi Timur,
If you hold down the shift key as you click a cell on a TStringGrid
component it will select multiple adjacent cells in the rectangle formed
by the cell you have clicked with the shift key down and the cell you
previously did a click on.
Tested with VCL. I think the same applies to FMX grid.
Hope this helps, Regards, Roger
Log in to reply.
  • Roger Cigol
  • Roger Cigol's Avatar
  • OFFLINE
  • Gold User
  • Rank: 33
  • Points: 85
  • Thanks 16
1 week 1 day ago #7831
Hi Timur,
That's interesting: just tried Firemonkey and the TStringGrid behaves differently.
Does anyone know how to select multiple fields on TStringGrid on firemonkey?
You could of course write your own code to handle clicks and to draw "selected
cells" (that your code would have to keep track of) using the OnDrawCell event,
but this could become quite involved....
Regards, Roger
Log in to reply.
The following user(s) said Thank You: Timur T7253
  • Timur T7253
  • Timur T7253's Avatar
  • OFFLINE
  • Gold User
  • Rank: 89
  • Points: 6
5 days 16 hours ago #7903
Thanks for your answer Roger Cigol. Now I am working on OnDrawColumnCell event( actually I couldn't find OnDrawCell(which you suggested) event under events tab under TStringGrid object, there is OnDrawColumnCell event, did you mean that?). I think I will be able to do what I am trying to do by using OnDrawColumnCell event but if I can't do it I will post another question here.
I think TSringGrid object should have this property built-in inside Firemonkey.
Log in to reply.
  • Roger Cigol
  • Roger Cigol's Avatar
  • OFFLINE
  • Gold User
  • Rank: 33
  • Points: 85
  • Thanks 16
5 days 6 hours ago #7912
Hi Timur,
In VCL the event is OnDrawCell and is fired for all cells in the string grid.
In FMX the event is OnDrawColumnCell and is fired only for non-column header cells.
(and there is another event: OnDrawColumnHeader that is fired for the column headings).
Regards, Roger
Log in to reply.
Moderators: Carlos Perez