How to initialize that windows form and all its components fit into full desktop screen automatically(no matter what resolution) without having to manually change every component by changing Anchor or by initializing the max and min size. I want to set that max and min size are the same. User won't be able to resize app.
Asked
Active
Viewed 1,755 times
0
-
Anchor every component to top, bottom, left & right and set form's WindowState property to Maximized. – Marko Juvančič Dec 29 '16 at 11:41
-
1Possible duplicate of [How do I make a WinForms app go Full Screen](http://stackoverflow.com/questions/505167/how-do-i-make-a-winforms-app-go-full-screen) – Prajwal Dec 29 '16 at 11:44
-
Not a duplicate. Its not about maximizing WindowState. Its about resizing all its components automatically. I tried it in VS Blend and still some components just wont resize properly. – hcerim Dec 29 '16 at 11:49
1 Answers
1
To initialize a form to fit into the full desktop screen, you need to do something like this:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
}
}
or if you need to specify a specific screen, you can do also this:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
//in this case I will show the form in my secondary screen.
var screen = Screen.AllScreens.Last();
this.Bounds = screen.Bounds;
}
}
}
To have all your controls automatically resized, you can use the TableLayoutPanel for it.
Here is a nice tutorial.

Pedro Simões
- 237
- 2
- 10