Reputation:
System.Windows.Forms.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
WindowState = System.Windows.WindowState.Maximized;
I am trying to set the FormBorderStyle
to None (to get fullscreen) but I I always get an error that the
FormBorderStyle is used as a variable.
Upvotes: 0
Views: 1632
Reputation: 26989
See this line of code that you have. This line works because it is saying that the WindowState
is assigned the value on the right.
WindowState = System.Windows.WindowState.Maximized;
Then you have this line of code:
System.Windows.Forms.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
That is similar to doing something like this:
int = int; // will not work
Both on the left and right side you have a type. You need to change it to this:
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Now you are saying that FormBorderStyle
of current window is the value on the right.
EDIT
In WPF you will do it like this:
this.WindowStyle = WindowStyle.None;
Upvotes: 1
Reputation: 10401
You are trying to set type to one of its possible values, so it's not going to work.
You need to assign the Form.FormBorderStyle
property on the instance of that form in some event handler or inside its constructor.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
}
...
Also you can probably set this property through the designer if your application never has to have another border style.
Upvotes: 1