I have a windows form and picture box on it, wich has anchor property set to Top, Bottom, Left, Right. Size mode is set to Normal, which is important. The problem is that when picture box is empty, it resizes with the form, but once I set an image to it, when I resize form, it stays the same size. The only idea I have in order to fix this is to save image temporarily, clear picture box, then once it's resized count scaling value, resize picture and then set it back, but as for me it's a pretty lame approach. Is there any way I can do it simplier?
Asked
Active
Viewed 3,296 times
0
-
1Is the property SizeMode set to Auto? Or Stretch? – Oct 04 '14 at 17:57
-
@Hypenate, as I wrote, Size mode is set to Normal, which is important – KorsaR Oct 05 '14 at 22:27
3 Answers
1
You need to change your picturebox properties...
PictureBox.SizeMode = SizeMode.Stretch;

Padhu
- 1,590
- 12
- 15
-
1I don't need stretch, as I wrote before, size mode is set to Normal, which is important – KorsaR Oct 05 '14 at 22:28
-
Try Reading This, http://stackoverflow.com/questions/15534955/resize-an-image-in-a-picturebox-to-as-large-as-it-can-go-while-maintaining-aspe?rq=1 – Padhu Oct 05 '14 at 22:58
-
The thing is that I need specifically Normal size mode in order to pan the image and be able to zoom it. Problem is that pictureBox doesn't resize in this mode when it has an image inside. – KorsaR Oct 06 '14 at 11:35
0
I tried it...
Anchor: Top, Bottom, Left, Right
SizeMode: Normal
Load image in picturebox:
var ofd = new OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pictureBox1.ImageLocation = ofd.FileName;
}
I can resize the form and the picturebox resizes with the form --> it works.
May you have changed another property, which avoids the resizing?

BDL
- 21,052
- 22
- 49
- 55

BlueSalamander
- 3
- 3
0
Go to the form's Designer.cs and under the PictureBox entries, add the following:
this.PictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
That way, no matter what size you re-size the window to, the image will take up the full space of the window.

Mighty Ferengi
- 746
- 3
- 8
- 22