Resizing a form to shrink or grow according to the controls that are added

  • Thread starter Thread starter illegal.prime
  • Start date Start date
I

illegal.prime

Hi all, I realize this should be obvious, but I don't know what I'm not
doing. I have a form to which I add a variable number of controls.
All I need the form to do is to shrink or grow according to the size of
the controls added.

I suppose I could manually calculate the dimensions that the controls
occupy and then manually set the Form's dimensions. But there has to
be a more automatic way - I thought the AutoScale property being true
would handle this, but I think that only scales the controls as the
Form is resized - not vice-versa.

Thanks for any suggestions,
Novice
 
Correction - I am adding the controls to a panel that is docked to the
top of the form.

Novice
 
So right now, I have it working by adding up the control sizes and
setting the form size accordingly. This will suffice for now - until I
get a better suggestion.

One other thing I notice is that there are three striped diagnol lines
in the bottom right hand corner - indicating the user can resize the
form. I don't want to allow that - how can I both make the form
non-resizeable and remove those diagnol lines.

Thanks again,
Novice
 
Ah - I can just set the FormBorderStyle to FixedDialog.

Now if anyone has a better suggestion for the form resizing I would be
thankful. I seem to remember there is a ShrinkToFit property or
something like that. The code currently works, but no sense in
inventing my own way of doing something when it is already done and
more importantly in a standard way.

Thanks,
Novice
 
Back
Top