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.

Recommended Answers

All 6 Replies

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

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 )

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.