How to block the application from minimizing C#

Asked

Viewed 69 times

0

Guys, I have a windows form app that after opening a new screen it’s minimizing alone and I’m not able to figure out why.

All the screens I call as follows

Home PagHome = new Home();
PagHome.Show();
this.Close();

And when starting the Forms, I load the following code

  this.WindowState = FormWindowState.Maximized;
  this.FormBorderStyle = FormBorderStyle.None;
  this.MaximizeBox = false;
  this.MinimizeBox = false;

No error is appearing, and the screen is opening, however after opening it is minimizing.

Does anyone have any idea what it might be?

  • Well I performed several tests using Visual Studio 2017 and with this code you posted I did not see any error. But you have already checked if you are not using this.Close() in the main form ? .

1 answer

1

I can’t test now because I’m on my cell phone, but I think you can use the form Resize event:

private void Form1_Resize(object sender, EventArgs e) {
    if (WindowState == FormWindowState.Minimized) {
    this.WindowState = FormWindowState.Normal;
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.