Change Background Image and DA
Change Background Image and DA
In this tutorial, you will learn how to change a form background, and choose
a style.
For this tutorial you need a button, 5 radio buttons and OpenFileDialog
Change Background button click event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim OpenFileDialog1 As New OpenFileDialog
With OpenFileDialog1
.CheckFileExists = True
.ShowReadOnly = False
.Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
.FilterIndex = 2
If .ShowDialog = DialogResult.OK Then
Me.BackgroundImage = Image.FromFile(.FileName)
End If
End With
End Sub
Center:
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton2.CheckedChanged
Me.BackgroundImageLayout = ImageLayout.Center
End Sub
Stretch:
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton3.CheckedChanged
Me.BackgroundImageLayout = ImageLayout.Stretch
End Sub
Zoom:
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton4.CheckedChanged
Me.BackgroundImageLayout = ImageLayout.Zoom
End Sub