Daniel Cisek
Daniel Cisek

Reputation: 931

C# Form shows with size than other what was set

I'm setting form size to 0 and show it with code below:

Form overlay = new Form();
overlay.Size = new Size(0, 0);
overlay.Show();

But when the Form is shown, it's size is 140x39px. In constructor of overlay I set it size to 0. What can be the cause of this behaviour?

Upvotes: 0

Views: 224

Answers (3)

Fenton
Fenton

Reputation: 250812

If you pass 0, the assumption is you don't care about the size and default sizes are calculated based on what needs to be displayed.

You can test this using:

Form overlay = new Form();
overlay.Size = new Size(100, 100);
overlay.Show();

If this size works, passing 0 may be equivalent to automatic.

Upvotes: 0

aef
aef

Reputation: 66

If you want to hide your form use Hide() method.

Upvotes: 1

Douglas Barbin
Douglas Barbin

Reputation: 3615

You need to check the MaximumSize and MinimumSize properties on the Form. You are probably trying to set a size smaller than MinimumSize.

Upvotes: 4

Related Questions