If I set AutoSize = true on an UltraLabel, its height becomes fixed and its width expands/collapses to accommodate its text.
What I can't figure out is how to fix its width and have the UltraLabel autosize its height to accommodate the height of the wrapped text.
We're migrating from a set of custom controls where we had FixedWidthVariableHeight and FixedHeightVariableWidth layout options. I really need to find a way of achieving FixedWidthVariableHeight.
Please don't tell me I have to roll this myself and measure text. :)
Thanks for your help!Jim Honeycutt
Hi Jim,
The control doesn't natively support this.But there is a kind of sneaky way you can do it.
What you do is derive a control from UltraLabel and override the constructor and set AutoSizeHeightOnly to true.
class UltraLabelWithAutoHeight : UltraLabel { public UltraLabelWithAutoHeight() : base() { this.AutoSizeHeightOnly = true; } }
Note that the designer will not let you change the Width of the control once AutoSize is set to true. So this is a little inconvenientto work with at design-time. But it's easier than measuring the text yourself.
I'm having this problem with 2012.1 but when I try to inherit and set AutoSizeHeightOnly I get a "Deprecated" message, which says to use MaxSize and AutoSize combined to achive this behavior... but actually I couldn't get it to work... where's the trick?
Hi,
I think in order for this to work, you would have to set both the MinimumSize.Width and the MaximumSize.Width to the same value. This would lock the width of the control while still allowing the control to autosize it's height.