Version

Scroll a Node into View

This topic will show you how to bring a particular node into the viewable area of the tree. A node may not be visible for several reasons. It’s parent could be collapsed or it could be scrolled out of view either vertically or horizontally.

  1. Before you start writing any code, you should place using/imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.

In Visual Basic:

Imports Infragistics.Win.UltraWinTree

In C#:

using Infragistics.Win.UltraWinTree;
  1. You will need a reference to the node. If you know the key of the node, you can get a reference using the GetNodeByKey method of the tree.

In Visual Basic:

Dim aNode As UltraTreeNode
aNode = Me.UltraTree1.GetNodeByKey("Bind WinGrid to a Flat Data Source")

In C#:

UltraTreeNode aNode;
aNode = this.ultraTree1.GetNodeByKey("Bind WinGrid to a Flat Data Source");
  1. Once you have a reference to the node, you can call the BringIntoView method.

In Visual Basic:

aNode.BringIntoView()

In C#:

aNode.BringIntoView();
  1. The code in the previous step will bring the node into the viewable area of the tree. It will scroll the tree and expand any parent nodes as necessary to bring the node into view. However, the exact location of the node could be anywhere inside the viewable area.

If you want more control, you can set the TopNode property of the control. This will move the node to the top of the viewable area.

In Visual Basic:

Me.UltraTree1.TopNode = aNode

In C#:

this.ultraTree1.TopNode = aNode;