private void RadTreeView1_NodeExpandedChanged(object sender, RadTreeViewEventArgs e)
{
if (e.Node.Expanded)
{
TreeNodeElement firstVisibleNode = this.radTreeView1.TreeViewElement.ViewElement.Children[0] as TreeNodeElement;
if (firstVisibleNode != null)
{
//move scrollbar from top to bottom
while (firstVisibleNode.Data != e.Node)
{
if (this.radTreeView1.TreeViewElement.VScrollBar.Value == (this.radTreeView1.TreeViewElement.VScrollBar.Maximum - this.radTreeView1.TreeViewElement.VScrollBar.LargeChange - 1))
{
break;
}
this.radTreeView1.TreeViewElement.VScrollBar.Value = Math.Min((this.radTreeView1.TreeViewElement.VScrollBar.Value + 1),
(this.radTreeView1.TreeViewElement.VScrollBar.Maximum - this.radTreeView1.TreeViewElement.VScrollBar.LargeChange - 1));
Application.DoEvents();
firstVisibleNode = this.radTreeView1.TreeViewElement.ViewElement.Children[0] as TreeNodeElement;
}
if (firstVisibleNode.Data != e.Node)
{
//move scrollbar from bottom to top
while (firstVisibleNode.Data != e.Node)
{
if (this.radTreeView1.TreeViewElement.VScrollBar.Value == 0)
{
break;
}
this.radTreeView1.TreeViewElement.VScrollBar.Value = Math.Max((this.radTreeView1.TreeViewElement.VScrollBar.Value - 1), 0);
Application.DoEvents();
firstVisibleNode = this.radTreeView1.TreeViewElement.ViewElement.Children[0] as TreeNodeElement;
this.radTreeView1.TreeViewElement.EnsureVisible(firstVisibleNode.Data);
}
}
}
}
}
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik