Home > DeveloperSection > Articles > PictureBox Control in C#.Net

PictureBox Control in C#.Net


C# C# 
Ratings:
0 Comment(s)
 10311  View(s)
Rate this:

PictureBox Control in C#.Net

PictureBox control is used to display image. It contains properties and method to manipulate the image.

Drag and drop the PictureBox control from toolbox on the Window Form.

PictureBox Control in C#.Net

Code:

Write code in the Form_Load event

Example:

private void frmPictureBox_Load(object sender, EventArgs e)

{

   //show picture  in PictureBox

   pictureBox1.Image = Image.FromFile("C:\\Users\\image1.png");

}

FromFile method is used to find the image.

Run the project

Image will show in the PictureBox when application run.

PictureBox Control in C#.Net

Properties of PictureBox:

Size Mode:  Set the Image size mode   by default it set to Normal.

Example:

private void frmPictureBox_Load(object sender, EventArgs e)

{

       //set sizemode to CenterImage

       pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;

}

Centre image will show in PictureBox.

PictureBox Control in C#.Net

BorderStyle:  Set the border style for the control. 


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

Follow MindStick