1.
Execute the following button event
Private void btnformmax_click (Object sender, eventargs E)
{
If (this. windowstate = formwindowstate. maximized)
{
This. windowstate = formwindowstate. normal;
}
Else
{
This. windowstate = formwindowstate. maximized;
}
}
When the form is maximized, the taskbar is not covered in full screen mode.
This. formborderstyle is sizable by default.
2.
Execute the following button event
Private void btnformmax_click (Object sender, eventargs E)
{
If (this. windowstate = formwindowstate. maximized)
{
This. windowstate = formwindowstate. normal;
}
Else
{
This. formborderstyle = formborderstyle. None;
This. windowstate = formwindowstate. maximized;
}
}
When the form is maximized, the full screen and the taskbar are overwritten.
In this case, if this. formborderstyle is set to none, related information such as the form title bar is not displayed.
3.
Execute the following button event
Private void btnformmax_click (Object sender, eventargs E)
{
If (this. windowstate = formwindowstate. maximized)
{
This. windowstate = formwindowstate. normal;
}
Else
{
This. formborderstyle = formborderstyle. None;
This. maximumsize = new size (screen. primaryscreen. workingarea. Width, screen. primaryscreen. workingarea. Height );
This. windowstate = formwindowstate. maximized;
}
}
When the form is maximized, the full screen does not cover the taskbar.
In this case, if this. formborderstyle is set to none, related information such as the form title bar is not displayed.
Setting full screen is to set the windowstate attribute and formwindowstate attribute of the form, as shown in the simple code found on the internet above. However, in actual process, the display of the status bar cannot be controlled, sometimes, the task bar is hidden, but it does not work. The experiment is summarized as follows:
// 1. The maximization operation must first formborderstyle. None and then formwindowstate. maximized. // otherwise, the taskbar cannot be overwritten. // 2. If formwindowstate. maximized is already in use, you must first set it to a status other than formwindowstate. maximized. // otherwise, formwindowstate. maximized does not work and violates the content. If (this. windowstate = formwindowstate. maximized) {This. hide (); this. windowstate = formwindowstate. normal;} This. formborderstyle = formborderstyle. none; this. windowstate = formwindowstate. maximized; this. show ();
In fact, formborderstyle. None also affects the value of a series of properties in winform, such as screen. primaryscreen. workingarea, used to obtain the available screen range.