Unplanned
Last Updated: 04 Jun 2020 09:51 by ADMIN
Marc
Created on: 04 Jun 2020 09:43
Category: TreeView
Type: Feature Request
1
RadTreeView: make expanded node fully visible like MS TreeView
Please refer to the attached gif file for better illustration.
1 comment
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 04 Jun 2020 09:51
Hello, Marc, 

Indeed, this behavior can be improved. The possible solution that I can suggest is to handle the NodeExpandedChanged event make the affected node the first visible node into the view. Thus, all of its child nodes that fit on the screen will be displayed. The attached gif file illustrates the achieved result:
 
        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);
                        }
                    }
                }
            }
        }
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.