How to change the shape vertically and horizontally when control grows?

(WinForms.net 2.0)

I am making a form that, like the standard MessageBox , has one label on it and should grow horizontally and vertically if the text on the label grows. The horizontal image seems simple enough by setting AutoSize = true on the label and in the form. However, I also want the label to grow vertically, i.e. If it has newlines, but it doesn’t look so easy. I am sure that this is so, but what settings are necessary for the shortcut and form to grow vertically? I have the shortcut Anchor = top, left, right, bottom installed, so I would think that when the text with the newline characters was set on the label, the label height will increase, and with Anchor = top & bottom it will make the form increase the height, It seems it does not happen. What am I missing?

+4
source share
1 answer

set Autosize=True and AutoSizeMode=GrowAndShrink on the form. Also, make sure that your controls are automatically loaded into their contents and will not snap to all four sides.

+9
source

All Articles