简体   繁体   中英

How to resize a PictureBox while maintaining its Aspect Ratio

I have a Windows Forms application where I let the user resize a PictureBox. But it's pretty useless because it does not maintain its aspect ratio as the user makes it smaller or larger.

How can I do this? I know how to resize a picturebox normally with mouseDown, mouseMove and mouseUp events, but how to make sure it keeps its aspect ratio?

Change SizeMode = Zoom on the PictureBox . That will keep the aspect ratio for your image.

The only side-effect you may not want is that it will also make the image larger than the original, if you increase the size of the form enough, resulting in a fuzzy looking image.

You can make the IMAGE inside the PictureBox to keep it aspect ratio... using SizeMode = Zoom

The PictureBox can be resized to any size, but the image will kept its aspect ratio within the PictureBox boundaries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM