0% found this document useful (0 votes)
48 views

Change Background Image and DA

This tutorial shows how to change a form's background image and style using a button click event to open a file dialog and set the background image, and radio button checked changed events to set the background image layout to Tile, Center, Stretch, Zoom, or remove the image.

Uploaded by

Carlos Morales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Change Background Image and DA

This tutorial shows how to change a form's background image and style using a button click event to open a file dialog and set the background image, and radio button checked changed events to set the background image layout to Tile, Center, Stretch, Zoom, or remove the image.

Uploaded by

Carlos Morales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Change Background Image and Style

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

Tile Style radio button code:


Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton1.CheckedChanged
Me.BackgroundImageLayout = ImageLayout.Tile
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

To remove background image:


Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RadioButton5.CheckedChanged
Me.BackgroundImage = Nothing
End Su

You might also like