How can I make a form fill all the screen (in terms of size) when clicked (not
fullscreen like f11
). At design - time (Not on code behind)?
Asked
Active
Viewed 460 times
-1
-
@OlivierRogier yes – Oct 03 '19 at 15:34
2 Answers
1
If I understand your question correctly, making your form in run time isn't an problem but you want to design also in that form size. You could just set your form's height and width properties according to your resolution. Like for 1366x768, width-1366 height-768.
Yes, Resolution differences will be a major problem and I don't see anything you can do other than building an responsive layout. In that case design size doesn't matter (full screen or not).

halfer
- 19,824
- 17
- 99
- 186

Lakshith Nishshanke
- 117
- 7
0
At design time: use the WindowsState
property defined to Maximized
.
At runtime without using this property: you can use this:
static public class FormHelper
{
static public void SetSizeToScreen(this Form form)
{
int left = Screen.PrimaryScreen.Bounds.Left;
int top = Screen.PrimaryScreen.Bounds.Top;
int width = Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Height;
form.Location = new Point(left, top);
form.Size = new Size(width, height);
}
static public void SetSizeToDesktop(this Form form)
{
int left = SystemInformation.WorkingArea.Left;
int top = SystemInformation.WorkingArea.Top;
int width = SystemInformation.WorkingArea.Width;
int height = SystemInformation.WorkingArea.Height;
form.Location = new Point(left, top);
form.Size = new Size(width, height);
}
}
Usage:
this.SetSizeToDesktop();
-
-
but it is code... I'm sorry if I'm being unclear. I ment to doing it in the form itself, (changing properties, adding controls etc...) Not in code. the porpus of this restriction is shorter code and resorces saving – Oct 03 '19 at 15:39
-
*At design time, use the WindowsState property defined to Maximized.* or I don't understand the question. – Oct 03 '19 at 15:40
-
-
It is already done. I've edited the answer while you read it not finalized. Sorry. – Oct 03 '19 at 15:43