C# - How to open form in full screen
This example shows how to make open windows form full screen of computer.
In this example, i will use F11 as a shortcut key to turn form to full screen.
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
In this example, i will use F11 as a shortcut key to turn form to full screen.
Step By Step :
- Create one windows form project
- Add Form 2 in the solution.
- Add method to event Key Up in Form 1
- Copy code below in Key Up event method Form 1
The Code
private bool _bFullScreenMode = false;
:
:
:
private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if ( e.KeyData == Keys.F11)
{
if (_bFullScreenMode == false)
{
Form2 f = new Form2();
this.Owner = f;
this.FormBorderStyle = FormBorderStyle.None;
this.Left = (Screen.PrimaryScreen.Bounds.Width/2 - this.Width/2);
this.Top = (Screen.PrimaryScreen.Bounds.Height/2 - this.Height/2);
f.Show();
_bFullScreenMode = true;
f.KeyUp +=new KeyEventHandler(Form1_KeyUp);
}
else
{
Form f = this.Owner;
this.Owner = null;
f.Close();
this.FormBorderStyle = FormBorderStyle.Sizable;
}
}
}
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)