PictureBox Control in VB.net – Properties, Methods and Events

What is PictureBox Control in VB.net?

The PictureBox Control in VB.net is used for displaying images on the form.

The Image property of the control allows you to set an image both at design time or at run time.

Let’s create a picture box by dragging a PictureBox control from the Toolbox and dropping it on the form.

PictureBox Control in VB.net Tutorial
VB.net PictureBox Control Tutorial

Properties of PictureBox Control in VB.net

The following given below are some commonly used Properties of the PictureBox Control in VB.net.

#PictureBox Control in VB.net PropertiesDescription
1.BackColorIt is used to set the background color for the PictureBox in the window form.
2.BackgroundImageIt is used to set the background image of a window form by setting or getting value in the picture box.
3.ErrorImageThe ErrorImage property is used to display an image if an error occurs while loading an image on a window form.
4.InitialImageThe 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.
5.WaitOnLoadIt represents whether the particular image is synchronized or not in the PictureBox control.
6.TextIt is used to set text for the picture box controls in the window form.
7.ImageThe image property is used to display the image on the PictureBox of a Windows form.
8.BorderStyleIt is used to set the border style for the picture box in the windows form.
9.ImageLocationIt is used to set or get the path or URL of the image displayed on the picture box of the window form.
10.IsMirroredIt obtains a value that determines whether the picture box control is mirrored.
VB.net Properties and Description of PictureBox Control

Methods of PictureBox Control in VB.net

The following given below are some commonly used Methods of the PictureBox Control in VB.net.

#PictureBox Control in VB.net MethodsDescription
1.CancelAysnc()The CancelAsync method is used to cancel an asynchronous image load in a PictureBox control.
2.CreateHandle()It is used to create handles for the picture box controls in window form.
3.DestroyHandle()It is used to destroy all the handles that are associated with the picture box control.
4.GetStyle()The GetStyle() method is used to get values for the specified bit style in the PictureBox control.
5.Load()The Load() method is used to load the specified image from the control using the ImageLocation property.
6.LoadAsync(String)It is used to asynchronous load the image at the specified position of the picture box control.
VB.net Methods and Descriptions of PictureBox Control

Events of PictureBox Control in VB.net

The following given below are some commonly used Events of the PictureBox Control in VB.net.

#PictureBox Control in VB.net EventsDescription
1.CausesValidationChangedOverrides the Control.CausesValidationChanged property.
2.ClickOccurs when the control is clicked.
3.EnterOverrides the Control.Enter property.
4.FontChangedOccurs when the value of the Font property changes.
5.ForeColorChangedOccurs when the value of the ForeColor property changes.
6.KeyDownOccurs when a key is pressed when the control has focus.
7.KeyPressOccurs when a key is pressed when the control has focus.
8.KeyUpOccurs when a key is released when the control has focus.
9.LeaveOccurs when input focus leaves the PictureBox.
10.LoadCompletedOccurs when the asynchronous image-load operation is completed, been canceled, or raised an exception.
11.LoadProgressChangedOccurs when the progress of an asynchronous image-loading operation has changed.
12.ResizeOccurs when the control is resized.
13.RightToLeftChangedOccurs when the value of the RightToLeft property changes.
14.SizeChangedOccurs when the Size property value changes.
15.SizeModeChangedOccurs when SizeMode changes.
16.TabIndexChangedOccurs when the value of the TabIndex property changes.
17.TabStopChangedOccurs when the value of the TabStop property changes.
18.TextChangedOccurs when the value of the Text property changes.
Events and Descriptions of PictureBox Control

Let’s create a program to display an image in VB.net Windows form.

Public Class Form1
    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        PictureBox1.Image = Image.FromFile("C:\Users\Lenovo\Desktop\pies.jpg")
        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        PictureBox1.Height = 500
        PictureBox1.Width = 800
    End Sub
End Class

Program Output:

PictureBox Control in VB.net Output
VB.net PictureBox Control Output

Now, click the view button to display the image in a Windows form.

PictureBox Control in VB.net Display Picture
VB.net PictureBox Control Display Picture

Summary

In this article we have discussed how to create a program for PictureBox in VB.net using Microsoft Visual Studio, we have learned how to use and manage the different Properties, Methods, and Events of the PictureBox in VB.net.


Common use cases for PictureBox Control

PictureBox Control is a standard Windows Forms element that appears in most VB.NET desktop apps. Typical uses:

  • User input capture. Bind to viewmodel properties for two-way data flow.
  • Display of collections. Populate with in-memory lists, database result sets, or file system contents.
  • Event-driven behaviors. Wire up Click, SelectedIndexChanged, or KeyDown handlers for interactivity.
  • Data validation. Use Validating and Validated events to enforce input rules before persistence.
  • Custom styling. Override OnPaint or use owner-draw modes for branded looks.

Wiring PictureBox Control into your form

The standard pattern for adding PictureBox Control at runtime looks like this:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ' Configure the control's initial state
        Me.Text = "PictureBox Control Example"
        ' Attach event handlers programmatically
        AddHandler MyControl.Click, AddressOf MyControl_Click
    End Sub

    Private Sub MyControl_Click(sender As Object, e As EventArgs)
        ' React to user interaction here
        MessageBox.Show("Control was clicked")
    End Sub

End Class

Best practices for PictureBox Control

  • Name controls consistently. Use a Hungarian-style prefix (btn, txt, lbl, lst) so the codebehind reads cleanly.
  • Group related controls in a Panel or GroupBox. Improves layout maintainability and keyboard tab order.
  • Set TabIndex explicitly. Do not rely on design-time order; keyboard navigation matters for accessibility.
  • Use data binding when possible. Avoid manual .Text = someValue assignments scattered across the codebehind.
  • Handle Dispose(). Custom controls that hold GDI resources must implement IDisposable properly.

Troubleshooting PictureBox Control

  • Event handler does not fire. Confirm the Handles clause matches the exact control name, or that AddHandler was called.
  • Design-time appearance differs from runtime. This usually means custom OnPaint code is not respecting DesignMode. Check with Me.DesignMode.
  • Control flashes or flickers on redraw. Enable double-buffering by setting DoubleBuffered = True on the parent form.
  • Cross-thread exceptions. UI updates from background threads must use Control.Invoke() or the BackgroundWorker.ReportProgress pattern.

Frequently Asked Questions

What is the PictureBox Control in VB.NET used for?
The PictureBox Control is a Windows Forms control that captures user input or displays data in a familiar UI element. It sits in the Toolbox in Visual Studio and can also be created at runtime through code.
How do I add the PictureBox Control to my form?
Drag it from the Visual Studio Toolbox onto the form designer, or instantiate it in code with New and add it to Me.Controls. Both approaches produce identical runtime behavior.
What are the most-used PictureBox Control properties?
Name, Text, Location, Size, and Enabled are set on almost every instance. Font, ForeColor, and BackColor are common for styling. Anchor and Dock control how the control resizes with the form.
How do I handle PictureBox Control events?
Double-click the control in the form designer to auto-generate a default event handler. Or wire up manually with AddHandler MyControl.EventName, AddressOf HandlerMethod inside Form_Load.
Can I use the PictureBox Control in WPF or MAUI?
No. Windows Forms controls are specific to WinForms. WPF has its own control hierarchy under System.Windows.Controls, and MAUI uses cross-platform equivalents. Use the framework-appropriate control instead.
Angel Jude Suarez


Full-Stack Developer at PIES IT Solution

Focuses on Python development, machine learning, and AI integration. Has built production AI systems including OpenAI Whisper integration for medical transcription and GPT-4o-powered diagnosis assistance. Strong background in pandas, scikit-learn, and TensorFlow.

Expertise: Python · PHP · Java · VB.NET · ASP.NET · Machine Learning · AI Integration · OpenCV · Django · CodeIgniter
 · View all posts by Angel Jude Suarez →

Leave a Comment