Select multiple lines in code

I have tried a lot of options in the AdvColumnGrid, but I can't find a way to select multiple lines. I want to be able to:

1. select multiple lines (not necessarily next to each other) in code. Or with the mouse.
2. unselect all lines in code.

You can do this by initializing the grid with:

  advcolumngrid1.Options := advcolumngrid1.Options + [goRangeSelect];
  advcolumngrid1.MouseActions.RangeSelectAndEdit := true;
  advcolumngrid1.MouseActions.RowSelect := true;
  advcolumngrid1.MouseActions.DisjunctRowSelect := true;

Ok, selecting bij Mouse (Left Click, Ctrl + LClick, Shift + LClick) and from code works now.
Two more questions:

1. How do I unselect all rows in a Grid in code?
2. When I have selected a number of rows and I deselect one by clicking on it the OnSelectionChanged event is NOT triggered
  1. You can call:
      advcolumngrid1.UnSelectRows(advcolumngrid1.FixedRows, advcolumngrid1.RowCount - 1);

    2. I have retested this here with a default grid initialized with
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      advcolumngrid1.Options := advcolumngrid1.Options + [goRangeSelect];
      advcolumngrid1.MouseActions.RangeSelectAndEdit := true;
      advcolumngrid1.MouseActions.RowSelect := true;
      advcolumngrid1.MouseActions.DisjunctRowSelect := true;
    end;

    and event handler:

    procedure TForm1.AdvColumnGrid1SelectionChanged(Sender: TObject; ALeft, ATop,
      ARight, ABottom: Integer);
    begin
      outputdebugstring('selection changed');
    end;

    and this works as expected also for unselect.
    Do you use the latest version of the grid?

When I test it in a simple testprogram it works ok. But not when the
same grid is in my main program. I will try to investigate what is
different.I do use the latest version of the grid.

Dear Bruno,


whith a TDBAdvGrid, I whant to unselect all rows after use the selected rows. I try like this:

 advcolumngrid1.UnSelectRows(advcolumngrid1.FixedRows, advcolumngrid1.RowCount - 1);
application.processmessages;

But the rows are not unselected.
My version is TDBAdvGrid version 2.4.5.4 Jan 2019 for Delphi 10.3 Rio

Any suggestion?

What are your grid settings and how did you apply the selection?

I've put  theese propeties (listed in this same Post)


  advcolumngrid1.Options := advcolumngrid1.Options + [goRangeSelect];
  advcolumngrid1.MouseActions.RangeSelectAndEdit := true;
  advcolumngrid1.MouseActions.RowSelect := true;
  advcolumngrid1.MouseActions.DisjunctRowSelect := true;

Now works fine.
First time, the mouseActions was in false

Many thanks