How to bring a TreeViewItem in the visible (scroll) area

  

I’m looking for a way to navigate by code to an item in a tree view. The object should be moved into the visible area. I could not find a method in either TTreeView or TTreeViewItem.

The following approach does not work under all circumstances because the item position is not always updated:

procedure TfmxMain.MakeItemVisible(Item: TTreeViewItem);
begin
trvMyTreeView.ViewportPosition :=
TPointF.Create(min(Item.Position.X – trvSlideGroups.ClientWidth / 2, 0),
min(Item.Position.Y – trvSlideGroups.ClientHeight / 2, 0));
end;

Comments are closed.