Mason Wheeler
Mason Wheeler

Reputation: 84550

How do I make a TTreeView display a node when I select it?

If I have a TTreeView, and I call something like this:

myTreeView.Select(nodeIWantSelected);

it gets selected, but unless that node happens to be located within the part of the tree that's currently visible, I don't see it and I have to drag the scroll bar around until I find its position. How can I make the TTreeView scroll to the node when I select it?

Upvotes: 3

Views: 2831

Answers (2)

dwrbudr
dwrbudr

Reputation: 66

Use nodeIWantSelected.MakeVisible

Upvotes: 4

Nick Dandoulakis
Nick Dandoulakis

Reputation: 43110

I can not test it right now but one of these might produce the desired effect:

myTreeView.Select(nodeIWantSelected);
myTreeView.Selected.MakeVisible;
// or
myTreeView.Selected.Focused := true;

Upvotes: 1

Related Questions