Picture Box Demo C#.NET PROGRAM

Picture box, which receives the path of image from string variable and displays the images with decided property when application will get run.
Form1.Designer.cs
namespace gui
{
    partial class Form1
    {
        private System.ComponentModel.IContainer components = null;
       
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace gui
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void SetPictureBoxSizeMode()
        {
            string path = @"C:\Pictures\0281012L.JPG";  // Change the path if needed.
            pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
            pictureBox1.Image = Image.FromFile(path);
            pictureBox2.SizeMode = PictureBoxSizeMode.Normal;
            pictureBox2.Image = Image.FromFile(path);
            pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox3.Image = Image.FromFile(path);
            pictureBox4.SizeMode = PictureBoxSizeMode.CenterImage;
            pictureBox4.Image = Image.FromFile(path);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SetPictureBoxSizeMode();
        }
    }
}

OUTPUT
 
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *