1
  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;
}
Jimi
  • 29,621
  • 8
  • 43
  • 61
  • If the Form is maximized (I assume you're trying to set it back to normal state. This: `this.MaximizeBox = false;` hides the Button), then just `this.WindowState = FormWindowState.Normal;`. Btw, don't do this: `pictureBox5.Image = null;` to remove an Image, dispose of it instead: `pictureBox5.Image?.Dispose();`. Unless the property is referencing an existing Bitmap object that you want to use again later. – Jimi Oct 04 '20 at 03:15
  • Did you store the original size somewhere? – TaW Oct 04 '20 at 10:22
  • @Jimi, thank you for the enlightment, the `pictureBox5.Image?.Dispose()` its a very good solution. As for the `this.WindowState = FormWindowState.Normal;` didnt worked, neither the `this.Size = new Size(890; 662);`. @TaW, I did set the MinimumSize to (890; 662), but didn`t work either when i reset it. I think that might have to do with any of the properties set in the Properties Window. (https://cdn.discordapp.com/attachments/732768066261483522/762508932140236840/unknown.png) (https://cdn.discordapp.com/attachments/732768066261483522/762509040328245299/unknown.png) – rodrigo alencar Oct 05 '20 at 02:58

1 Answers1

0

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#