Recent

Author Topic: StringGrid: add selection via code  (Read 1155 times)

SirTwist

  • New Member
  • *
  • Posts: 21
StringGrid: add selection via code
« 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
« Last Edit: June 23, 2019, 11:07:13 pm by SirTwist »

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: StringGrid: add selection via code
« Reply #1 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


);
The only true wisdom is knowing you know nothing

SirTwist

  • New Member
  • *
  • Posts: 21
Re: StringGrid: add selection via code
« Reply #2 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.

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: StringGrid: add selection via code
« Reply #3 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
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018