RadTreeNode Bounds property

3 posts, 0 answers
  1. Alex
    Alex avatar
    30 posts
    Member since:
    Aug 2010

    Posted 19 May 2011 Link to this post

    How can I get node bounding rectangle? There is no BoundingRectangle or Bounds or smth like this in RadTreeViewNode class.
  2. Alex
    Alex avatar
    30 posts
    Member since:
    Aug 2010

    Posted 20 May 2011 Link to this post

    Wrote this method, is there an easier way?
           
    public static Rectangle GetBounds(this RadTreeNode node)
    {
        var nodeElement = node.TreeViewElement.ViewElement.Children
            .Cast<TreeNodeElement>()
            .FirstOrDefault(c => c.Data == node);
        if (nodeElement != null)
        {
            return nodeElement.BoundingRectangle;
        }
        else
        {
            int y = 0;
     
            RadTreeNode radTreeNode = node.TreeView.Nodes[0];
            if (radTreeNode == null)
            {
                throw new InvalidOperationException();
            }
            while (radTreeNode != node)
            {
                y += radTreeNode.ActualSize.Height;
                radTreeNode = radTreeNode.NextVisibleNode;
            }
            int itemHeight = radTreeNode.ActualSize.Height;
            var offset = node.TreeView.VScrollBar.Value;
            Rectangle bounds = new Rectangle(0, y - offset, node.TreeViewElement.Bounds.Width, itemHeight);
            return bounds;
        }
    }



  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 25 May 2011 Link to this post

    Hello Alex,

    RadTreeView uses layered architecture and RadTreeNode is just a logical object. The user interfaces uses virtualization and creates visual elements only for the nodes that are currently visible on screen. This improves the performance and and lowers the memory usage. Only the visual element - TreeNodeElement has a BoundingRectangle property. Yes, your solution will do the job. However, please elaborate a bit more and describe what exactly you want to achieve. This will help me to understand the issue and find the best option.

    I look forward to your reply.
     
    Regards,
    Jack
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top