Completed
Last Updated: 08 May 2014 11:57 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 23 Apr 2014 08:26
Category: TreeView
Type: Bug Report
0
IMPROVE. RadTreeView - RadTreeNode.EnsureVisible and RadTreeView.BringIntoView methods does not work as expected when called in the NodeExpandedChanged event
Add a RadTreeView with several hierarchy levels. Initially all nodes are collapsed. When you collapse each child node deeper in the hierarchy, use the following code snippet:

public Form1()
{
    InitializeComponent();

    radTreeView1.CollapseAll();
    radTreeView1.TreeViewElement.AutoScrollOnClick = false;
}

private void radTreeView1_NodeExpandedChanged(object sender, RadTreeViewEventArgs e)
        {
            if (e.Node.Expanded)
            {
                e.Node.LastNode.EnsureVisible();
                radTreeView1.BringIntoView(e.Node.LastNode);
            }
        }
		
The last child node is visible, regarding the height, however, the entire node is not visible, regarding the width.

Workaround: use RadTreeView.MouseUp event instead.

private void radTreeView1_MouseUp(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        TreeNodeExpanderItem expander = radTreeView1.ElementTree.GetElementAtPoint(e.Location) as TreeNodeExpanderItem;
        if (expander != null && expander.Expanded && expander.NodeElement.Data != null)
        {
            radTreeView1.BringIntoView(expander.NodeElement.Data.LastNode);
        }
    }
}

0 comments