Solved

moving a treeview's scrollbars to the top of the treeview

Posted on 2004-10-14
3
961 Views
Last Modified: 2006-11-17
I am trying to move the scrollbars of a treeview control to the top of the control.  When I add a large number of nodes and expand all the nodes via code, the treeview control moves to the bottom of the treeview.  I want the scrollbars to be at the top of the treeview.  I am pretty sure you can do this using the windows API SendMessage() function, but I dont know what values to give to the function to get it to work.  If there is a way to do it using c# code instead of the API call I would prefer to do that.

Thank You
0
Comment
Question by:clintonm9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:Kahhoe
ID: 12315870
Add the code below:

directoryTreeView.AfterExpand += new TreeViewEventHandler(directoryTreeView_AfterExpand);

private void directoryTreeView_AfterExpand(object sender, TreeViewEventArgs e)
{
     while(directoryTreeView.SelectedNode.Parent!=null)
     {
          directoryTreeView.SelectedNode = directoryTreeView.SelectedNode.Parent;
     }

     directoryTreeView.SelectedNode.EnsureVisible();
}

hope this is what you want..
0
 
LVL 11

Expert Comment

by:jatinderalagh
ID: 12316007
Hi

just check this link. It's working for scrolling panel programatically.
But from the available source code u will get all the information about API's
to play with ScrollBars

http://www.codeproject.com/cs/miscctrl/CustomAutoScrollPanel.asp

Hope it will help
Cheers
Jatinder
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 125 total points
ID: 12318802
Why not just:

if (myTreeView.Nodes.Count > 0)
  myTreeView.Nodes[0].EnsureVisible();
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question