Solved

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

Posted on 2004-10-14
3
962 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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!
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

624 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