user7313850
user7313850

Reputation:

Setting formBorderStyle to None fails with error FormBorderStyle is used as a variable

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.

enter image description here

Upvotes: 0

Views: 1632

Answers (2)

CodingYoshi
CodingYoshi

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

Eugene Podskal
Eugene Podskal

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

Related Questions