Reputation: 2724
I'm wanting my winform to conform to the size of an image I pass to an image box held on my form. When I start the program it looks like this:
Then when I pass an image to my picture box it reshapes to this:
However, what I actually want is for the winform to resemble this. I had to manually drag the window to get it this way:
I'm not entirely sure how I can achieve the third one via code. At the moment this is what i have:
this.Size = new Size(imagePreview.Width, imagePreview.Height);
Is there something else I can do code wise so i always end up with the result in the third picture, no matter what size of the image?
Upvotes: 1
Views: 2025
Reputation:
There is one built-in property that could help you - Size Mode. Try it and if this does not suit your needs you can implement your own method for this - click me!
Upvotes: 1