Search code examples
c#winforms.net-3.5

How do I programmatically scroll TreeView?


I need to scroll TreeView (Windows Forms) from TOP to BOTTOM...

I should clarify that I have two TreeViews... If the first was scrolled by the user, the second treeView must be automatically scrolled. I don't know what node is selected...

How can I do this?


Solution

  • For top node:

    TreeView.Nodes[0].EnsureVisible();
    

    For bottom node:

    TreeView.Nodes[TreeView.Nodes.Count-1].EnsureVisible();