1

I'm working on a Win Forms project where I'm trying to create an button to toggle full screen on/off every time i click the button,so if you click once, it becomes full screen, if you click again, it becomes normal again. please tell me how to do that.

  • Not an exact duplicate but should be useful. Just add a click handler. https://stackoverflow.com/questions/505167/how-do-i-make-a-winforms-app-go-full-screen – Sangram Nandkhile Mar 02 '20 at 06:23
  • i need it to load with normal mode , but when i click the button turn it to full and click it again to turn it to normal again ...etc i want the button go on/off full screen –  Mar 02 '20 at 06:28
  • 1
    You can use [`FullScreen`](https://stackoverflow.com/a/32821243/3110834) custom property. – Reza Aghaei Mar 02 '20 at 07:24

1 Answers1

0

I am not sure about the exact requirements but this should help you.

Add Form1_Load and button1_Click events.

private void Form1_Load(object sender, EventArgs e)
{
    // Normal when the form opens
    WindowState = FormWindowState.Normal;
}

private void button1_Click(object sender, EventArgs e)
{
    // Toggle on a button click
    WindowState = WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal;
}
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Sangram Nandkhile
  • 17,634
  • 19
  • 82
  • 116