Logging Experiences

Tips and Tricks: Making Windows Forms Size to Their Content

Posted in C#, Programming, Tips and Tricks by Sina Iravanian on August 15, 2010

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.

Tagged with: ,

6 Responses

Subscribe to comments with RSS.

  1. archive.today said, on October 1, 2014 at 3:50 am

    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.

  2. Guillermo said, on October 4, 2014 at 11:07 am

    My brother recommended I would possibly like this website.
    He was totally right. This post truly made my
    day. You can not imagine just how much time I had spent for this info!
    Thank you!

  3. record storage shelving said, on October 6, 2014 at 5:56 am

    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!

  4. northernprairiechevre.net said, on October 6, 2014 at 10:25 am

    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?

  5. goldinvestmentsconnection said, on October 6, 2014 at 1:10 pm

    Appreciating the persistence you put into your blog and
    detailed information you provide. It’s great to come across
    a blog every once in a while that isn’t the same outdated rehashed material.

    Wonderful read! I’ve saved your site and I’m
    adding your RSS feeds to my Google account.

  6. i said, on October 9, 2014 at 2:20 am

    I have read so many articles or reviews regarding the blogger lovers however
    this article is actually a nice post, keep it up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: