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 si开发者_JAVA技巧des 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?
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.
Try setting the picture box's AutoSizeMode = GrowAndShrink. I usually leave the form's AutoSizedMode = GrowOnly, because if you forget to set some of the minimum sizes on your controls, it will always try to be the minimum size.
精彩评论