Tom Knowlton
asked on
Moving scrollbar to top of TTreeView after expanding the entire tree
I have a TTreeView with lots of stuff. When I click on the button to expand the tree, it expands, but the scrollbar is left at the bottom of the TTreeView when the tree is done expanding. After the Tree expands, I want to move the scrollbar back up to the top of the Tree listing.
How is this done?
How is this done?
ASKER
Edited text of question.
listening
From delphi help:
TopItem
Specifies the topmost node that appears in the tree view.
property TopItem: TTreeNode;
Description
When TopItem is changed, the tree view scrolls vertically so that the specified node is topmost in the list view.
TopItem
Specifies the topmost node that appears in the tree view.
property TopItem: TTreeNode;
Description
When TopItem is changed, the tree view scrolls vertically so that the specified node is topmost in the list view.
To be frank, I have an idea, but I find it messy. I give it to you for what it is : you could simulate the click of the mouse by sending the appropriate messages to the ttreeview window.
much better than my messy idea
you can write:
with yourtreeview do begin
selected:=items[0];
end;
it like calvinday said, it move current selection ,and the scrollbar will move to the top.
with yourtreeview do begin
selected:=items[0];
end;
it like calvinday said, it move current selection ,and the scrollbar will move to the top.
Try this:
TreeView1.Items[0].MakeVis ible;
If you see it scroll to the bottom, then quickly to the top again, then use BeginUpdate and EndUpdate to prevent the redraw.
TreeView1.Items.BeginUpdat e;
try
TreeView1.FullExpand;
TreeView1.Items[0].MakeVis ible;
finally
TreeView1.Items.EndUpdate;
end;
Cheers,
Phil.
TreeView1.Items[0].MakeVis
If you see it scroll to the bottom, then quickly to the top again, then use BeginUpdate and EndUpdate to prevent the redraw.
TreeView1.Items.BeginUpdat
try
TreeView1.FullExpand;
TreeView1.Items[0].MakeVis
finally
TreeView1.Items.EndUpdate;
end;
Cheers,
Phil.
ASKER
phillipleighs:
You get the points. Your code worked just as you typed it. Please repost your comment as an answer.
Tom
You get the points. Your code worked just as you typed it. Please repost your comment as an answer.
Tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You're welcome
ASKER