rombez
rombez

Reputation: 2198

Can't run a simple WinForms app, shows a default unchanged form

I am reading a book of HF series on C# and have to do a first simple WinForms app, which contains a button, a checkbox and a label. I created the controls and an event handler for the button with code, didn't make any changes to other files, just the Designer and the file with C# code (don't know how it is called properly).
Saved it all.

Program content

When I try to run the program (F5 or Ctrl+F5), VS shows me a default form as if it was blank and without any elements.

How the program looks when executed

What am I doing wrong?

Upvotes: 0

Views: 103

Answers (2)

Echtelion
Echtelion

Reputation: 171

If the above solution is not working :

In your program.cs, your probably call Application.Run(new Form()) instead on Application.Run(new Form1())

You instantiate a default form, and not the class you created.

Upvotes: 1

thewisegod
thewisegod

Reputation: 1542

Add the following code inside of Form1.cs:

  public Form1()
  {
        InitializeComponent();
  }

Upvotes: 2

Related Questions