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

RadLabel, WordWrap and TextAlignment

2 Answers 489 Views
Label
This is a migrated thread and some comments may be shown as answers.
Marek
Top achievements
Rank 1
Marek asked on 23 Aug 2007, 01:19 PM
The temporary fix that I have for the auto size problem for a label control has addressed one issue but raised another.  My label spans a number of lines of text and the word wrap feature (default?) is what I need.  However when I set TextAlignment to any of the left (or right) flavors (top-left, bottom-left etc.) I seem to get the top row left or right aligned, but the subsequent rows middle aligned based on the position of the first row. I hope this makes sense?  Is this a bug?

Best regards

Marek

2 Answers, 1 is accepted

Sort by
0
Marek
Top achievements
Rank 1
answered on 23 Aug 2007, 02:01 PM
I'm now assuming that I should also be adding:

RootElement.StringAlignment = StringAlignment.Near;

Is this right?
0
Angel
Telerik team
answered on 24 Aug 2007, 03:46 PM
Hello Marek,

The solution you have found will work fine.

Here is a short explanation why the label is acting the way you described. For RadLabel TextAlignment means alignment of the text primitive that is inside the control, not the way in which the text is painted. The functionality you need is controlled by the TextPrimitive and its property StringAlignment.

Your code sets the same property to the root element and that property is propagated to the primitive. In order to see and manipulate the properties of TextPrimitive you must click "Edit UI elements" from the Action List of RadLabel and select the tree item that starts with "Text:".

We agree that the behavior of RadLabel's TextAlignment is not obvious and differ from the behavior of Microsoft's Label. In one of the upcoming releases the label's API will be refactored in order to achieve more consistent behavior with other labels as well as to expose the rich painting functionality in a better way. Now the only way to have full control of TextPrimitive painting functionality is to access non-browsable property PaintTextFormat.

For example, to disable painting of a line of text that is only partially visible you must use code like this:

TextPrimitive primitive = (TextPrimitive)this.radLabel1.RootElement.Children[0].Children[2];
primitive.PaintTextFormat.FormatFlags |= StringFormatFlags.LineLimit;


which is not the easiest and most intuitive way.


Kind regards,

Angel
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
Tags
Label
Asked by
Marek
Top achievements
Rank 1
Answers by
Marek
Top achievements
Rank 1
Angel
Telerik team
Share this question
or