Picturebox Control in VB.NET
PictureBox control allows user to display an image on the form. User can display image either design time or run time using Picture Box Control.
Properties of Picturebox Control in VB.NET
| Property | Purpose |
Image |
It is used to get or set an image to be display in the PictureBox. |
ErrorImage |
It is used to get or set an Error Image that display when loading of Image specified in Image property is failed. |
InitialImage |
It is used to get or set an initial Image that display when an Image specified in Image property is not loaded. |
ImageLocation |
It is used to get or set path or url of image to be display in PictureBox Control. |
SizeMode |
It is used to get or set the SizeMode. SizeMode determines how an image will display in PictureBox. It has five options: |
WaitOnLoad |
It is used to specify weather processing of an image is stop until it is loaded or not. It has Boolean value. Default value is False. |
Enabled |
It is used to specify weather PictureBox Control is enabled or not at runtime. It has Boolean value. Default value is true. |
Visible |
It is used to specify weather PictureBox Control is visible or not at runtime. It has Boolean value. Default value is true. |
Methods of Picturebox Control in VB.NET
| Method | Purpose |
Load |
It is used to display an image whose path or url is specified in ImageLocation Property of PictureBox. |
LoadAsync |
It is used to load an image Asynchronously. |
CancelAsync |
It is used to cancel Asynchronous loading of an image. |
Events of Picturebox Control in VB.NET
| Event | Purpose |
Click |
It is the default event of PictureBox. It fires each time user clicks on PictureBox. |
SizeModeChanged |
It fires each time a SizeMode property of the PictureBox is changed. |
Example of Picturebox Control in VB.NET
Design an application that display selected image in a PictureBox control. Provide facility to stretch image.
Step 1: Design a form as shown below:

Step 2: Now set properties of various controls as given below:
| Control Name | Property Name | Value |
Form1 |
Text |
PictureBox Demo |
PictureBox1 |
Name |
PictureBox1 |
Button1 |
Name |
cmdLoad |
Text |
Select Image To Load |
|
Button2 |
Name |
cmdStretch |
Text |
Stretch Image |
|
OpenFileDialog1 |
Name |
OpenFileDialog1 |
Filter |
Image|*.jpg |
Step 3: Double click on Select Image To Load button and write following code to display image in Picture Box.
PictureBox1.Image = Image.FromFile (OpenFileDialog1.FileName)
End If
Step 4: Now Double click on Stretch Image Button and write following code to stretch image.
Step 5: Now Double Click on PictureBox and write following code in SizeModeChanged event of PictureBox: