Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-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!
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now