Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 214157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:20:51+00:00 2026-05-11T18:20:51+00:00

I have a form with some controls. (Actually, this is a sort of ongoing

  • 0

I have a form with some controls. (Actually, this is a sort of ongoing problem.) Some of the forms I have had are resizable, some are not. Regardless, when the form is displayed, it would be nice to have it appear in the “minimum” size needed. Other Windowing toolkits, such as wxWidgets (wxWindow::GetMinSize) and Qt (QWidget::minimumSize) have this functionality.

This functionality, if you are not familiar with it, allows a window to resize itself to a minimum size, which is often all the window needs, and looks quite nice. If I have two static texts, and two edit boxes laid out thusly:

Username:
[ Edit/text box for user's password]
Password:
[ Edit/text box for user's password]
              [  Cancel  ][   OK   ]

I can then tell this form to size itself to it’s “minimum size”, and it would appear much like above. (Minimum width in a text box is partly subjective – I would have to set that myself in one/both of the text boxes, but the form would query the child controls and learn of that minimum width)
This is usually combined with layouts of some sort. (Which .Net has.)

This has the added benefit that the form is the correct size regardless of font settings, locale, dpi, gui skin, etc. (If done right, at least.)

Does this exist in .Net, and if so, where? If you need any more description, ask, and I’ll be glad to provide.

Edit: What I’m looking for is the above example, resizable only in the X direction (I’m willing to accept both) but can’t be resized smaller than a certain W/H. The controls should anchor – ie, the text boxes get bigger, the buttons stay right aligned.

Edit: I can do images! Supposedly they’re worth a thousand words:
alt text http://www.freeimagehosting.net/uploads/79e9ee10e5.png

Edit: I guess I’m going to start marking answers. Henk’s answer has gotten me pretty far with a non-resizable dialog that fits to it’s contents. Most of the posts below are valuable, but miss the point (unless I’m really off base here?): I understand how to use Anchor/TableLayout, and to get controls to flow there – it was mostly getting one or both dimensions of the dialog to fit to the contents of the dialog. You essentially have three cases:

  1. The dialog is not resizable – See Henk’s answer. Combined with TableLayout and Anchors, you’ll get a decent dialog.

  2. The dialog is only resizable in one dimension – Go with 1 or 3 – You can constrain a dimension by using the Resize event, but the dialog flickers horribly. (This seems to be a defect in Win32 as far as I can tell – there is some stuff out there about overriding the background erase, which works for controls, but not windows, as you’ll get artifacts in the form’s background (because you’re not erasing them). The real answer is that this should probably be handled by Win32 itself – I should not have to reinvent the double-buffer wheel just to get a decent look dialog…))

  3. The dialog is fully resizable. Anchors and TableLayout are your friend. Unfortunately, the MinimumSize attribute seems to be bogus (at least, I don’t know what it is for…) – for example, if you query the MinimumSize of a textbox, by default the height is 4 pixels. Further, the MinimumSize property doesn’t seem to propogate – a control does not query it’s children. (I can resize the form smaller than the textbox within the form, and the textbox is then off the form.) If you wonder what I’m babbling about, see wxWidgets and how layouts and minimum size work for it.

I’ve also since discovered that .Net does not seem to respect the system font, and always uses the same font for Forms, so font changes won’t affect my dialog (sadly) which alieviates most of my worries (happily?). Again, refer to how wxWidgets does it – if the system font is 22pt, all wxFrames (forms) respect and resize appropriately. .Net should get onboard this train… (And I know someone who uses 22+pt font day-to-day for their standard GUI font.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:20:51+00:00Added an answer on May 11, 2026 at 6:20 pm

    There is something that comes close, try the following: design your Form a bit large and avoid Right and Bottom docked controls. Then some code like this:

    private void button1_Click(object sender, EventArgs e)
    {
        this.AutoSize = true;
        this.Size = new Size(10, 10);
    }
    

    The AutoSize will find the extend of the Controls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with some controls (extJs and ASP) like this: <ext:ComboBox ID=Countries
I have a form and a sub-form, both with some controls that are bound
I have an MVC page, with some controls inside a form. The part I
I have an asp.net form that contains some html, 2 controls a calendar from
I apologize in advance, I am a PHP noob! I have form with some
I have a form with some ToolStrips, MenuStrips and a DataSet on it. Lately
I have next form and some ashx <form action=FileUpload.ashx method=POST enctype=multipart/form-data id=frmUpload> <input id=fileupload
I have a form with some input fields. I am using the tabStrip KendoUI
I have a form with some input fields and a little <div> to the
I have a form with some tags under it. When you click each tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.