I have a user control, which has a label.
I want to put some multi line text in the label, and have the label and user control resize vertically.
AutoSize seems to only size the label horizontally, not vertically.
Any help for this?
Thanks,
Matthew
The text in the label has CRLF?
The text in the label is created by the user in page of the app – using TinyEditor, so I imagine that would be “<br>” – label is set to allowhtml.
Try this:
private void button1_Click(object sender, EventArgs e)
{
this.label1.Text = this.tinyEditor1.Text;
Wisej.Base.TextUtils.MeasureTextAsync(this.label1.Text, true, this.label1.Font, (size) => {
this.label1.Size = size;
});
}
HTML text has to be measured on the client using Wisej.Base.TextUtils.MeasureTextAsync.
If you the set containing Panel to AutoSize=true and fix the Minimum and Maximum Width it will grow vertically to fit the content. May have to change the AutoSizeMode to GrowAndShrink if you want the panel to shrink.
There is also a bug with the regular AutoSize implementation of Label and Button not considering CRLF to grow vertically and not using the Min/Max constraints.
Hi Matthew,
WJ-8566 and WJ-8567 are fixed in the latest Wisej release (1.4.50).
Best regards
Frank
I am noticing that the label’s autosize is not really working. At runtime, I am setting a new text (2 words) and it seems that it is not displaying the 2nd word, like the label borders are not wide enough when autosize = true. Is this a bug that has already been fixed?
Also, on the previous note about using MeasureTextAsync, how do you write this example in VB.NET ?
Thanks in advance
Robert
Please login first to submit.