PictureBox control is used to display image. The images displayed can be any format like Bitmap, JPEG, and GIF, PNG or any other image format files. The PictureBox control is based on the Control class.
How to use PictureBox control
Drag and drop the PictureBox control from toolbox on the Window Form.
Code:
Public Class Form13
Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'show image in PictureBox
PictureBox1.Image = Image.FromFile("C:\Pictures\Sample Pictures\image1.png")
End Sub
End Class
FromFile method is used to find the image.
Run the project
Image will show in PictureBox when application run.
Size Mode property of PictureBox: Set the Image size mode by default it set to Normal.
Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'set sizemode to CenterImage
PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage
End Sub
Centre image will show in PictureBox.
Leave Comment