RadLabel Size is 0

2 posts, 0 answers
  1. Nadina
    Nadina avatar
    1 posts
    Member since:
    Apr 2012

    Posted 16 May 2012 Link to this post

    Is there any way to get the RadLabel size when it is created via runtime?

    I am trying to calculate the height of a container control by summing the height properties of the controls added to the container.

    When create a new object instance of a RadLabel in code such as this:

    Dim p_Label as New RadLabel

     . .  the width and height properties are set to 0 and remain at zero even after setting the text property.

    I was looking for some type of Resize method that could be called after setting the .Text and .Font property, but have been unable to find such a way to cause the control to recalculate its size.

    A point of clarification: after adding the RadLabel to a container the height property is always 1, which is not really the case.
  2. Stefan
    Stefan avatar
    2911 posts

    Posted 17 May 2012 Link to this post

    Hello Nadina,

    Thank you for writing.

    You can use the Form.Load event to instantiate the label, set its properties and add it to the Controls collection of the form. At this place it should report its correct size:
    Dim lAs New RadLabel()
    l.Text = "asdasd"

    I hope this helps. Let us know if you have any other questions.
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top