Home > DeveloperSection > Articles > PictureBox Control in VB.Net

PictureBox Control in VB.Net


VB.Net VB.Net 
Ratings:
0 Comment(s)
 10708  View(s)
Rate this:

PictureBox Control in VB.Net

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.

PictureBox Control in VB.Net

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.

 

PictureBox Control in VB.Net

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.

PictureBox Control in VB.Net


Don't want to miss updates? Please click the below button!

Follow MindStick