user2843703
user2843703

Reputation:

C# application maximized window

First the resize window button doesn't want to work ,for some reason.

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

And even if i make the form maximized from the VS form properties from this http://postimg.org/image/mmy9r7qu9/ ,the form turns into this http://postimg.org/image/kzeyrb9fb/ .What is going on?

Upvotes: 0

Views: 118

Answers (2)

Pouya
Pouya

Reputation: 109

  1. Click on the Form
  2. Go to it's properties
  3. Find the option: "WindowState"
  4. Change it to "Maximized"

You can also see an image about this option in: https://www.mediafire.com/view/nmnf8wcjsl1zi6z/WindowState.bmp

And you can try this for a "Button_Click":

private void FullScreenButton_Click(object sender, EventArgs e)
{
    if (this.WindowState == FormWindowState.Normal)
    {
        this.WindowState = FormWindowState.Maximized;
    }
    else
    {
        this.WindowState = FormWindowState.Normal;
    }
}

Upvotes: 1

David Betournay
David Betournay

Reputation: 1

You are negating the first if-statement with the second if-statement, try using an else-if.

private void FullScreenButton_Click(object sender, EventArgs e)
    {
        if (this.WindowState == FormWindowState.Normal)
        {
            this.WindowState = FormWindowState.Maximized;
        }
        else if (this.WindowState==FormWindowState.Maximized)
        {
            this.WindowState = FormWindowState.Normal;
        }
    }

As for the Maximized sizing issue, do you have the Form's MaximumSize property set to "0,0" or some other value that could be limiting it's maximum size?

Upvotes: 0

Related Questions