Label.AutoSize is failing to alter Width property.

  • Thread starter Thread starter Patrick Lioi
  • Start date Start date
P

Patrick Lioi

Label label = new Label();
label.Width = 1;
label.AutoSize = true;
label.Text = "A long string, requiring a width larger than 1.";
//At this point, Width is still 1.

What am I missing? Shouldn't AutoSize adjust the "Size"
"Auto"matically to fit the string?
 
Hi Patrick,

The Width property doesn't update until you add the Label to the Controls
collection of the Form (or whichever Parent you'd like).
 
Back
Top