Skip to content

Instantly share code, notes, and snippets.

@Owez
Created April 3, 2018 16:50
Show Gist options
  • Save Owez/f1a3871608971110ab570c917ca908ef to your computer and use it in GitHub Desktop.
Save Owez/f1a3871608971110ab570c917ca908ef to your computer and use it in GitHub Desktop.
C# Maximize button | full code (will maximized if it is normal and go back to normal if pressed again)
// Maximise button (when clicked)
private void buttonMaximise_Click(object sender, EventArgs e)
{
if (this.WindowState == System.Windows.Forms.FormWindowState.Normal) // if the forms state is normal (not maximised or minimised) then..
{
this.WindowState = FormWindowState.Maximized; // Tells windows this application should be maximised
}
else if (this.WindowState == System.Windows.Forms.FormWindowState.Maximized) // if the forms state is maximised then..
{
this.WindowState = FormWindowState.Normal; // Tells windows this application should be in the normal state (not maximised or minimised)
}
}
@stoasis
Copy link

stoasis commented Jan 4, 2024

Works perfectly - thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment