Label.AutoSize is failing to alter Width property.

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?
 
D

Dave Sexton

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top