Dynamically resize a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a UserControl called TimeEntry, which at runtime I am adding to
dynamically created form like so:

Form myForm = new Form();
TimeEntry myTime = new TimeEntry();

myForm.size = myTime.size;
myForm.Controls.Add(myTime);
myForm.ShowDialog();

as you can see I am trying to resize the form to fit the control on to, but
it doesnt seem to work, it sizes it but not enough. Why is this?

Steve
 
The "ClientSize" property of the Form should do what you want...

Form myForm = new Form();
TimeEntry myTime = new TimeEntry();
myForm.ClientSize = myTime.Size;
myForm.Controls.Add(myTime);
myForm.ShowDialog();
 
Superb, cheers!

Tim Wilson said:
The "ClientSize" property of the Form should do what you want...

Form myForm = new Form();
TimeEntry myTime = new TimeEntry();
myForm.ClientSize = myTime.Size;
myForm.Controls.Add(myTime);
myForm.ShowDialog();
 
A little question about it.
What is the properties to let the users to resize a WinForm with the bottom
right angle?

Thanks a lot.

Luigi
 
A little question about it.
What is the properties to let the users to resize a WinForm with the
bottom
right angle?

Set the SizeGripStyle property to Show.
 
Back
Top