Home > Software design >  Keeping selection in TTreeView after OnExit
Keeping selection in TTreeView after OnExit

Time:05-27

I have a TTreeView component I use to display the hierarchical structure in a form and I'd like to be able to select some components and "manipulate" them e.g. clicking a button to move them.

My problem is as soon as I click the button the selected objects vanish.

I've seen that in the TCustomTreeView class there is a DoExit procedure:

procedure TCustomTreeView.DoExit;
begin
  inherited;
  InvalidateSelectionsRects;
end;

I tried to override this method so InvalidateSelectionRects is not called to no avail.

Is there a way to keep the (multiple) selected elements while doing interactions outside the TTreeView?

Edit: With the tip provided by Delphi listing

CodePudding user response:

Set the HideSelection property of the tree view to False

TreeView.HideSelection := false;
  • Related