Lazarus

Programming => LCL => Topic started by: SirTwist on June 23, 2019, 09:37:11 pm

Title: StringGrid: add selection via code
Post by: SirTwist on June 23, 2019, 09:37:11 pm
Hi all,

I have a TStringGrid (actually a derived StringGrid...) and want to add rows to the selection by program code.
The StringGrid is configured to have Multi Ranges (RangeSelectMode = rsmMulti), that's how I try to emulate "MultiSelect" in Listboxes or ListViews.

When the user changes selection via mouse, I can read SelectedRangeCount and SelectedRange\[i\].

But I want to add rows (or cells) [edited:] to the selection ranges via code.

Is there any way to add SelectedRanges?

Kind regards,
SirTwist
Title: Re: StringGrid: add selection via code
Post by: jamie on June 23, 2019, 09:53:37 pm
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index]   Reference for unit 'Grids' (#lcl)

TCustomStringGrid.InsertRowWithValues

Declaration

Source position: grids.pas line 1723

 
public procedure TCustomStringGrid.InsertRowWithValues(


  Index: Integer;


  Values: array of string


);
Title: Re: StringGrid: add selection via code
Post by: SirTwist on June 23, 2019, 11:06:32 pm
Ah, I'm sorry, my mistake. I do not want to add new rows to the StringGrid, but add rows to the selection.
Title: Re: StringGrid: add selection via code
Post by: jamie on June 24, 2019, 03:10:17 am
well, you already know it  :)

Selection!

Selection:TRect....

 Read it to give you the selection, write it to set it.
 
I am going to bed, good night
TinyPortal © 2005-2018