Rizwan Khan
Rizwan Khan

Reputation: 401

Change the Display size of Image on Form resizing

I want that when i resize the form, Image Display resize with form size automatically

private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
        openFileDialog1.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp; *.png";
        if(openFileDialog1.ShowDialog() == DialogResult.OK){
            pictureBox1.ImageLocation = openFileDialog1.FileName;
            //pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
        }
    }

Suggest me some code please

Upvotes: 0

Views: 1119

Answers (1)

Damith
Damith

Reputation: 63105

try

pictureBox1.Dock = DockStyle.Fill;

and

pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

Edit

pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;

Upvotes: 2

Related Questions