This is what I am trying to accomplish...
I want the ultralable to autosize width up to a maximum, and i want it to autosize height and wrap text.
So I have
myLabel.WrapText=true;
myLabel.AutoSize = true;
myLabel.MaximumSize = (200,0);
This does not work. It only expands the width up to the specified maximum. The label will not grow as necessary in height to display the text. Is there some other way to accomplish this or am I missing something?
I'm not sure I see how this would work. AutoSizing the label involves measuring the text. In order to do that, either the width or the height has to be fixed. If both are variable, then there are any number of potential ways that the text would be displayed. You could have 5 words on a single line or 1 words on each of 5 lines.
There's no way to measure text in Windows that I know that allows you to specify a Maximum width - only a specific width. So in order for any control to accomplish what you want here, the control would had to measure the text with a width of 200. If the text wrapped at this point, that would be fine and it could determine the appropriate height. But if it was less, then it would basically have to measure the text over and over again with decreasing widths to find the point where it stopped wrapping. That would be pretty inefficient - although I guess it wouldn't be so bad since it only happens when the text changes.
Now, if you want to set the width of the label to 200 and only autosize the height, that would be possible. What you would do is derive a class from the UltraLabel and override the AutoResizeHeightOnly property and return true.
Actually there is a windows component that does this. The message box for windows form controls adjusts its message area by width/height to fit the text of the message.
It first expands the width up to a maximum for the window, then it expands in height.
Which is want i want. I want it to expand until the width is used up, and then wrap text and expand height.
To see what i mean you can use this code...
MessageBox.Show("A message");
MessageBox.Show("A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message, A message");
In my experience, the MessageBox has certain threshholds. There's a certain minimum width that it always uses until you reach a certain number of lines. Then it bumps up to a bigger width. Most MessageBox's don't display a huge amount of text, so they are all about the same size. You will not see any difference in the size of a MessageBox with 1 letter in it or 10.
But anyway, I concede that this is possible to accomplish - it would just require a lot of string measurement. For a MessageBox, it's a one-shot thing. The measurements are done once and the message box is display once and that's it. So the efficiency of the measurements isn't all that important.
For a Label that is always visible, efficiency of the measurements is probably still not that vital, since the text is not likely to change very often, if at all.
But the UltraLabel does not have this functionality at the moment. You are welcome to Submit a feature request to Infragistics.