onSelectionChange in TAdvOutlooklist

In TAdvOutlookList we can use Ctrl+A to select all rows in the List, but the onSelectionChange event does't fire. Yes i can use onKeyDown, but...

Do you use the latest version of the component, as I retested this with a default TAdvOutlookList on the form with:


procedure TForm5.AdvOutlookList1SelectionChange(Sender: TObject);
begin
  outputdebugstring('change sel');
end;

procedure TForm5.FormCreate(Sender: TObject);
begin
  advoutlooklist1.TestFill;
end;

and I see the OnSelectionChange event is also triggered when Ctrl-A is clicked.

Using V1.7.9.0 under D10.1 Berlin.


My bad, the onSelectionChange event fires. The Problem is, when i iterate over the Groups like that

var i,j   : integer;
   AGroup : TOutlookgroup;
    sl    : TStrings;
begin
  clear;
  for i:=0 to AOutlookList.GroupCount-1  do
   begin
    AGroup:=AOutlookList.Groups;
    for j := 0 to AGroup.ChildCount-1 do
     if AOutlookList.IsItemSelected (AGroup.ChildOGLItem[j]) then
      begin
       sl:=AGroup.ChildItem[j];
       // do the work with the Object
      end;
   end;
end; 

...the IsItemSelected delivers the wrong result. The row is selected, but the function say it is not selected.

I tested this once more with a default TAdvOutlookList on the form and the code:



procedure TForm1.Button1Click(Sender: TObject);
var
  i,j   : integer;
  AGroup : TOutlookgroup;
  sl    : TStrings;
begin
  for i:=0 to AdvOutlookList1.GroupCount-1  do
   begin
    AGroup := AdvOutlookList1.Groups;
    for j := 0 to AGroup.ChildCount-1 do
     if AdvOutlookList1.IsItemSelected(AGroup.ChildOGLItem[j]) then
      begin
       sl:=AGroup.ChildItem[j];
       // do the work with the Object
       outputdebugstring(pchar('is selected:'+inttostr(i)+':'+inttostr(j)));
      end;
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  advoutlooklist1.TestFill;
end;

and this outputs correctly all selected rows (after I do Ctrl-A)

If a problem persists, I propose you create some sample source project with detailed steps that shows the issue you experience and send it to our support by email so we can investigate, otherwise, this just remains guesswork on our side.

found the problem, onSelectionChange fires for every selected element. I thought only for the entire List. When i then iterate thru the list in the event Handler of onSelectionChange the list is unfinished.


So, thanks Bruno for the quick reply and help.

ps: an event onSelectionChanged that fires only one time for the List might be usefull. Hint, Hint ;) 

Yes, that might be useful and I added it on the list for consideration.

Thank's!

Hi Bruno,


any chance that we can have this event?

We have improved the component so it will for a select-all, only trigger OnSelectionChange once after all items are selected. The next update will have this improvement.

Perfect!!