Tips and Tricks: Making Windows Forms Size to Their Content

Windows In WPF can make use of a property which makes the window to automatically adjust its own size to fit its content. The related property in WPF is SizeToContent which can be set to Manual (the default), Width, Height and WidthAndHeight. The last item makes the window shrink or grow so that it will fit its content.

The same effect can be made in Windows Forms using the AutoSize and AutoSizeMode properties of the form. Simply set AutoSize to true and also do not forget to set AutoSizeMode to GrowAndShrink. This effect is not visualized during design.

6 Responses

An impressive share! I have just forwarded this onto a coworker
who was conducting a little research on this. And he actually ordered
me lunch due to the fact that I discovered it for him…
lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanks for spending time to talk about this issue here on your web site.

Hey there this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or
if you have to manually code with HTML. I’m starting a blog soon but have no coding
knowledge so I wanted to get advice from someone with experience.
Any help would be greatly appreciated!

I almost never write comments, however i did a few searching and wound up here Tips and Tricks: Making Windows Forms Size to
Their Content | Logging Experiences. And I do have a couple of questions for you if it’s allright.
Is it simply me or does it appear like some of the responses look like written by brain dead people?
😛 And, if you are posting at other sites, I would like
to keep up with everything new you have to post. Could you make a list of every one of your shared pages like your twitter feed,
Facebook page or linkedin profile?