Click here to Skip to main content
Rate this: bad
good
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 4:16am
Comments
JemiM at 5-Feb-13 9:25am
   
You mean fullscreen?
GopinathSk at 5-Feb-13 9:28am
   
yes
Kishor Deshpande at 5-Feb-13 9:25am
   
Adding solution..
JemiM at 5-Feb-13 9:31am
   
from which form you try maximize?
GopinathSk at 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 at 5-Feb-13 9:36am
   
Have you tried with my solution? It maximises all the forms in your application on button click :)..
GopinathSk at 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 at 5-Feb-13 9:41am
   
what's the problem now actually?
GopinathSk at 5-Feb-13 9:45am
   
sorry for confusing u...is it possible to increase the panel1 by code..
Kishor Deshpande at 5-Feb-13 9:58am
   
panel1.Dock=DockStyle.Fill;
is the answer :)
Kishor Deshpande at 5-Feb-13 9:50am
   
panel1.Dock=DockStyle.Fill;
Add this line of code..
GopinathSk at 5-Feb-13 9:57am
   
yeah it works very well sir.......thanks a lot
Kishor Deshpande at 5-Feb-13 10:00am
   
Gopinath: Could you please upvote my answer and accept it as solution??
Thanks. :)
JemiM at 5-Feb-13 9:53am
   
i have add a new solution.Please edit the current question to panel
Kishor Deshpande at 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 Smile | :)
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 at 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
0 BillWoodruff 360
1 Mathew Soji 309
2 Maciej Los 270
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 202
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
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