Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi TStringGrid multi select, determining selected rows

Is there anyway to determine which rows are currently selected in a multi-select TStringGrid, or a TCustomGrid for that matter. A property would be ideal.

I know that there is the gdSelected property that gets set in the DrawCell event,

procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState);

I can check AState for gdSelected, and keep track of this in an array somewhere, but this seems kludgey.

like image 310
sse Avatar asked Sep 10 '25 07:09

sse


2 Answers

I guess you are talking about a range-select string grid, that is, a string grid with goRangeSelect in Options. Then you can use the Selection property. This is (essentially) a TRect in which you can find the upper-left and lower-right cell in the range selection.

like image 125
Andreas Rejbrand Avatar answered Sep 12 '25 21:09

Andreas Rejbrand


Oooh, I'm use StringGrid.Selection.BottomRight.Y to determine rows and StringGrid.Selection.BottomRight.X for columns.

like image 31
Yuriy Avatar answered Sep 12 '25 19:09

Yuriy