Javatpoint Logo
Javatpoint Logo

VB.NET PictureBox Control

PictureBox control is used to display the images on Windows Form. The PictureBox control has an image property that allows the user to set the image at runtime or design time.

Let's create a PictureBox control in the VB.NET Windows form using the following steps.

Step 1: We have to find the PictureBox control from the toolbox and then drag and drop the PictureBox control onto the window form, as shown below.

VB.NET PictureBox Control

Step 2: Once the PictureBox is added to the form, we can set various properties of the image by clicking on the PictureBox control.

Properties of the PictureBox

There are following properties of the VB.NET PictureBox control.

Property Description
BackColor It is used to set the background color for the PictureBox in the window form.
BackgroundImage It is used to set the background image of a window form by setting or getting value in the picture box.
ErrorImage The ErrorImage property is used to display an image if an error occurs while loading an image on a window form.
InitialImage The initial image is used to display an image on the PictureBox when the main image is loaded onto a window form by setting a value in the PictureBox control.
WaitOnLoad It represents whether the particular image is synchronized or not in the PictureBox control.
Text It is used to set text for the picture box controls in the window form.
Image The image property is used to display the image on the PictureBox of a Windows form.
BorderStyle It is used to set the border style for the picture box in the windows form.
ImageLocation It is used to set or get the path or URL of the image displayed on the picture box of the window form.
IsMirrored It obtains a value that determines whether the picture box control is mirrored.

Methods of the PictureBox Control

Method Description
CancelAysnc() The CancelAsync method is used to cancel an asynchronous image load in a PictureBox control.
CreateHandle() It is used to create handles for the picture box controls in window form.
DestroyHandle() It is used to destroy all the handles that are associated with the picture box control.
GetStyle() The GetStyle() method is used to get values for the specified bit style in the PictureBox control.
Load() The Load() method is used to load the specified image from the control using the ImageLocation property.
LoadAsync(String) It is used to asynchronous load the image at the specified position of the picture box control.

Events of the PictureBox Control

There are some Events of the VB.NET PictureBox control.

Events Description
BackColorChanged It occurs when the property of the backcolor is changed in the PictureBox control.
BackgroundImageLayoutChanged It occurs when the property value of the BackgroundImage is changed in the PictureBox control.
ContextMenuChanged It occurs when the property of the ContextMenu is changed in the PictureBox control.
Resize The resize event occurs when the picture box control is changed.

Furthermore, we can also refer to VB.NET Microsoft documentation to get a complete list of PictureBox control properties, methods, and events in the VB.NET.

Let's create a program to display an image in the VB.NET form.

Picturebx.vb

Output:

VB.NET PictureBox Control

Now click on the Show button to display an image in the windows form.

VB.NET PictureBox Control





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA