Hello,
How do i resize/stretch the image inside a pictureBox(win32 form)?
i was only managed to resize/stretch the border of the pictureBox, but i want to resize/stretch the image itself, how do i do it?.
Thank you in advanced.

Use the BackgroundImageLayout property pictureBox1->BackgroundImageLayout = ImageLayout::Stretch; (then, once you resize the PB, the image should stretch with it)

Edited 6 Years Ago by jonsca: n/a

Thank you for your reply, i tried what you said but thats not exactly what i want.

Let me try to explain in more details(as english isn't my first language)

I have a pictureBox and when i load a image thats too big in it it only shows a small part of the image and thats not what i want, i want that when the image is bigger then the size of the pictureBox it gets resized to match the pictureBox size.

Can you post a bit of your code? Stretch should do that for you, are you applying it right after setting the background image?

I am using a button to load the image, here is the code i am using :

System::String ^lol;
				if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
					 {
				 lol=openFileDialog1->FileName;
				 pictureBox1->Load(lol);
				 pictureBox1->BackgroundImageLayout=ImageLayout::Stretch;
					}

Try it like pictureBox1->BackgroundImage = System::Drawing::Image::FromFile(filename); instead of line 5

Set your pictureBox SizeMode property to AutoSize.

this->pictureBox1->SizeMode = PictureBoxSizeMode::AutoSize;

This will resize the pictureBox to the size of the image.
Milton

Edited 6 Years Ago by Milton Neal: More info

This article has been dead for over six months. Start a new discussion instead.