articles

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

PictureBox Control in C#.Net

PictureBox Control in C#.Net

Pushpendra Singh 18393 24-Jan-2011

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

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

PictureBox Control in C#.Net

Code:

Write code in the Form_Load event

Example:

private void frmPictureBoLoad(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 frmPictureBoLoad(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. 


Read also this Article :-Print and Print Preview separately using HTML, CSS and JavaScript




c# c# 
Updated 04-Mar-2020

Leave Comment

Comments

Liked By