Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Winforms, no resize arrow using GrowAndShrink

I have a winform with a picture box, a button, and a menustrip. The picture box is anchored to all sides so when I resize the form, the picture box resizes as well. I set the form to have a minimum size of 700x600.

But this only works when the form is set to AutoSizeMode = GrowOnly. If I change to AutoSizeMode = GrowAndShrink, the diagonal <=> resize arrow doesn't even show up.

If I set the SizeGripStyle = Show on the form, I can get the arrow to show up and "resize" but as I drag it to resize, it just flickers really fast and goes back to default size.

How can I make it GrowAndShrink instead of just GrowOnly?

like image 483
Jack Avatar asked Jul 01 '11 02:07

Jack


1 Answers

Make sure the form properties have the following:

AutoSize: false (sounds like it should be true, but set this to false).
AutoSizeMode: GrowOnly (like above, sounds like it should be GrowAndShrink)
MinimumSize: Not important. set to 1, 1 for now. Is just to stop resizing getting too small.
MaximumSize: Not important. set to 1, 1. As above (MinimumSize).
SizeGripStyle: Not important. Set to Show. 

Lastly, ensure that you use anchoring or docking for adjusting control widths when the form resizes. Setting controls with a width may prevent you resizing the form.

like image 162
Valamas Avatar answered Oct 13 '22 14:10

Valamas