Saturday, 3 May 2014

C# - How to open form in full screen

Leave a Comment
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.

Step By Step :

  1. Create one windows form project
  2. Add Form 2 in the solution.
  3. Add method to event Key Up in Form 1
  4. 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
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 =)

0 comments:

Post a Comment

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.