Click here to Skip to main content
12,510,224 members (54,153 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
How to maximize the windows Form programmatically? with form size also
Posted 5-Feb-13 3:16am
Comments
JemiM 5-Feb-13 9:25am
   
You mean fullscreen?
GopinathSk 5-Feb-13 9:28am
   
yes
Kishor Deshpande 5-Feb-13 9:25am
   
Adding solution..
JemiM 5-Feb-13 9:31am
   
from which form you try maximize?
GopinathSk 5-Feb-13 9:35am
   
sir, now i create a simple notepad application in c#..In that i place a button for make the application into full screen...

yours answer is works only as form properties...

But i wanna to make the app full screen with its form
Kishor Deshpande 5-Feb-13 9:36am
   
Have you tried with my solution? It maximises all the forms in your application on button click :)..
GopinathSk 5-Feb-13 9:39am
   
yes i tried.first of all, i placed a panel1 in that form1 but panel1 is in same size
JemiM 5-Feb-13 9:41am
   
what's the problem now actually?
GopinathSk 5-Feb-13 9:45am
   
sorry for confusing u...is it possible to increase the panel1 by code..
Kishor Deshpande 5-Feb-13 9:58am
   
panel1.Dock=DockStyle.Fill;
is the answer :)
Kishor Deshpande 5-Feb-13 9:50am
   
panel1.Dock=DockStyle.Fill;
Add this line of code..
GopinathSk 5-Feb-13 9:57am
   
yeah it works very well sir.......thanks a lot
Kishor Deshpande 5-Feb-13 10:00am
   
Gopinath: Could you please upvote my answer and accept it as solution??
Thanks. :)
JemiM 5-Feb-13 9:53am
   
i have add a new solution.Please edit the current question to panel
Kishor Deshpande 5-Feb-13 9:56am
   
Jemi, you could have just modified your earlier answer, but anyways, he wants his panel to be of same size as of form not of size 200,200
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

private void button1_Click(object sender, EventArgs e)
{
    for (int i = 0; i < Application.OpenForms.Count; i++)
    {
        Application.OpenForms[i].WindowState=FormWindowState.Maximized;
    }
}
If you wish to have it maximised for only few types of forms, you can put if condition in that for loop.
These lines will make all openforms in your application maximised :)
Also for panel1,
Add line of code,
panel1.Dock=DockStyle.Fill;
Let me know if you need any more help..
  Permalink  
v5
Comments
Kishor Deshpande 5-Feb-13 10:27am
   
Thanks Abhishek for editing it. :)
I missed to add a code block for that line of code. :(
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

If you want to maximize the form programmatically, set the WindowState property to maximized.
this.WindowState = FormWindowState.Maximized;

If you want to set the window to full screen you can try like this:
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

You can maximize the form you want from another form like below
Form1 form1=new Form1();
          form1.Show();
          form1.WindowState = FormWindowState.Maximized;

Hope this helps
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100