PictureBox control is used to display images in Windows Forms. In this article, I will discuss how to use a PictureBox control to display images in Windows Forms applications.
Creating a PictureBox
PictureBox class represents a PictureBox control. The following code snippet creates a PictureBox, sets its width and height and adds control to the Form by calling Controls.Add() method.
C# Code
- PictureBox imageControl = newPictureBox();
- imageControl.Width = 400;
- imageControl.Height = 400;
- Controls.Add(imageControl);
VB.NET Code
- Dim imageControl AsNewPictureBox()
- imageControl.Width = 400
- imageControl.Height = 400
Display an Image
Image property is used to set an image to be displayed in a PictureBox control. The following code snippet creates a Bitmap from an image and sets the Image property of PictureBox control. Code also sets the Dock property of PictureBox.
C# Code
- privatevoid DisplayImage()
- {
- PictureBox imageControl = newPictureBox();
- imageControl.Width = 400;
- imageControl.Height = 400;
- Bitmap image = newBitmap("C:\\Images\\Creek.jpg");
- imageControl.Dock = DockStyle.Fill;
- imageControl.Image = (Image) image;
- Controls.Add(imageControl);
- }
VB.NET Code
- PrivateSub DisplayImage()
- Dim imageControl AsNewPictureBox()
- imageControl.Width = 400
- imageControl.Height = 400
- Dim Image AsNewBitmap("C:\\Images\\Creek.jpg")
- imageControl.Dock = DockStyle.Fill
- imageControl.Image = Image
- Controls.Add(imageControl)
- EndSub
The output looks like Figure 1 where an image is displayed.

SizeMode
SizeMode property is used to position an image within a PictureBox. It can be Normal, StretchImage, AutoSize, CenterImage, and Zoom. The following code snippet sets SizeMode property of a PictureBox control.
C# Code
- imageControl.SizeMode = PictureBoxSizeMode.CenterImage;
VB.NET Code
- imageControl.SizeMode = PictureBoxSizeMode.CenterImage
Summary
In this article, we discussed discuss how to use a PictureBox control to display images in Windows Forms applications.
Further Readings

Vy DonhuPosted Jun 4, 2021, 10:19 PM
Source code: https://github.com/donhuvy/PictureBoxSample
Areg GevorgyanPosted Feb 5, 2021, 9:29 PM
Thank you very much , this help me to solve my problem , Good luck !
Muhammad NadeemPosted Sep 15, 2018, 3:01 AM
Nice Article
Vishal anandPosted Jun 2, 2014, 3:39 AM
Sir your article is very nice! But i have one problem i have a StrokeScribe control and a label control inside picturebox control. So i want to display picturebox data which should contain both label and StrokeScribe control in c# windows forms upon creation. Tell me how to achieve it Sir? Reply please Sir? I am waiting for your reply?
rajinder mohanPosted Oct 14, 2012, 11:05 AM
If i want picture directly from scaaner to picturebox on button click then what is code for it
Mahesh ChandPosted Aug 24, 2010, 11:40 PM
Post comment here