简体   繁体   中英

How to make the size of a Form go back to the original size after an event is trigged?

  1. I tried to change the values with this.Height and this.Width , but it didn't work after I clicked the button. Any idea why it's not working?

  2. The PictureBox inside the Form worked with the same strategy though.

private void clear_ClickButton(object sender, EventArgs e)
{
    pictureBox5.Image = null;
    pictureBox5.Height = 500;
    pictureBox5.Width = 672;
    this.Width = 890;
    this.Height = 662;
    this.MaximizeBox = false;
    pictureBox7.Enabled = false;
}

First at all, I assume you speak about WinForm.

Form1.Size = new System.Drawing.Size(890, 662);

For more info How to: Resize Windows Forms and Change form size at runtime in C#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM