This is a migrated thread and some comments may be shown as answers.

RadLabel Size is 0

1 Answer 79 Views
Label
This is a migrated thread and some comments may be shown as answers.
Nadina
Top achievements
Rank 1
Nadina asked on 16 May 2012, 09:56 AM
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.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 17 May 2012, 02:53 PM
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"
Me.Controls.Add(l)
Console.WriteLine(l.Size)

I hope this helps. Let us know if you have any other questions.
 
Greetings,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Label
Asked by
Nadina
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or