RadLabel size is zero without a parent

2 posts, 0 answers
  1. Gary C
    Gary C avatar
    8 posts
    Member since:
    Nov 2008

    Posted 09 Dec 2009 Link to this post


    I'm using the Dec 3rd version of the WinForms components. After upgrading some of our forms don't look right. What I determined was a RadLabel created dynamically has a size of (0, 0) until it is assigned to a container. Is there a way to know the size of the RadLabel before it has a parent? Our current logic relies on the size of the labels to build the container form so it is broken because of this change.

    Here is some sample code to show the issue:

    RadLabel rl = new RadLabel(); 
    rl.Text = This is a test; 
    rl.Location = new Point(20, 20); 
    // rl.Size is (0,0) at this point 
    // now rl.Size is correctly showing (67, 14) in this test 


  2. Nikolay
    Nikolay avatar
    1805 posts

    Posted 11 Dec 2009 Link to this post

    Hi Gary C,

    The new behavior is a part of the Telerik Presentation Framework optimizations introduced in Q3 2009. Still, if you want your RadLabel to get a valid size before it is added to a parent container, you need to call the LoadElementTree method:

    public Form1()
        RadLabel rl = new RadLabel();  
        rl.Text = "This is a test";  
        rl.Location = new Point(20, 20);
        // at this points the size is (67, 14)  

    I hope this helps. If you have additional questions, feel free to contact me.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top