This documentation is archived and is not being maintained.

Picture will be tiled

Visual Studio .NET 2003

When a Visual Basic 6.0 PictureBox control is used as a control container, it is upgraded to a Visual Basic .NET Panel control rather than a PictureBox control, because the Visual Basic .NET PictureBox control cannot be used as a container.

In Visual Basic 6.0, an image specified by the Picture property would be displayed in the upper left corner of the PictureBox control; the AutoSize property determined whether the picture box would be resized to match the dimensions of the image. The Visual Basic .NET Panel control does not have an AutoSize property, so any image assigned to the BackgroundImage property will be tiled and the panel will not be automatically resized.

What to do next

  • Run the upgraded application and observe the behavior. If you are happy with the behavior, do nothing.
  • If the intended behavior was to resize the picture box to match the size of the image, resize the panel at design time.
  • If it is necessary to resize the panel when a new image is assigned at run time, add code similar to the following to the event handler that assigns the new image.
    ' Visual Basic .NET
    Picture1.BackgroundImage = _ System.Drawing.Image.FromFile("C:\SomePicture.bmp")
    Picture1.Height = Picture1.BackgroundImage.Height
    Picture1.Width = Picture1.BackgroundImage.Width

See Also

PictureBox Control Changes in Visual Basic .NET