Maintain a centered background image on a form when resizing

Posted in: Forms and Grids
By dePoPo
Jun 13, 2009 - 1:06:54 PM

The defeault background image for a form (normal or mdi) can be set from the desginer. However, when the form is resized, the image retains it's original location, and does not re-center to adjust to the new size.

To prevent this, simply reset the image from the resize event of the form, like below:

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

        Me.BackgroundImage = My.Resources.logoembossed

    End Sub


Visitor Comments