I have a PictureBox with Docking set to Fill. I would like to find the dimensions of the rectangle that the PictureBox "Fills".
In .NET 1.1, pictureBox1.height and pictureBox1.width properties define those dimensions.
In .NET 2.0, I find that the the height and width properties of the PictureBox defines the height and width of the image itself. In other words, the height and width properties no longer reflects the maximum space availiable to display the image.
How do I find those dimensions in .NET 2.0 It can't be the height width of the parent control, as Anchoring instead of Docking will yield different results. The motive for finding the max size is so I can manually resize the image while maintaining aspect ratio and not clip for an image viewer like the Windows XP image viewer.

Determining max size of Image in PictureBox (.NET 2.0)
Raphael Gabbarelli
vsphp
PictureBox directly derives from Control and doesn't alter the Size, Width or Height properties. The properties will eventually call SetWindowPos.
Are you really confident this is true
RameshPa_MSFT
private void pictureBox1_Resize(object sender, EventArgs e)
{
this.pictureBox1.Image = null;
}
vs.
private void pictureBox1_SizeChanged(object sender, EventArgs e)
{
this.pictureBox1.Image = null;
}
To replicate what I was experiencing:
- create a winform
- add a picturebox and dock fill
- set the color of picturebox to something that's different from the form color
- subscribe to the Resize event of picturebox with the resize snipet
- build, run, and resize the win form
- rebuild with sizechanged
Anyone have some insight into why this is
Kroamian
I am brand new to VB, started yesterday. But from what I read from your code and is that resize is called just before and /or during your resizing and sizechanged after you resized.
RvA
-Matt-
xBoRISx