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.
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.
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.
BorderStyle: Set the border style for the control.
Read also this Article :-Print and Print Preview separately using HTML, CSS and JavaScript
Leave Comment