14

I'm having a problem with the windows form application . When I create the windows form application , it displays the source code for the form but not the designer layout

freefaller
  • 18,589
  • 7
  • 54
  • 82
HR20dev
  • 161
  • 1
  • 1
  • 5
  • 1
    Be sure to pick the correct project template. VS2019 version 16.3.x will let you create a .NETCore project that targets Winforms, the designer however is not done yet. You need to select .NETFramework – Hans Passant Oct 14 '19 at 17:13
  • If you selected .NET Framework, you can try to open the designer using hotkey "Shift+ F7" – 大陸北方網友 Oct 15 '19 at 02:04
  • 1
    My suspicion is that you created a new WinForms project targeting .NET 3.0, which as Hans mentioned, requires a different winforms designer (still in preview), but can be downloaded from https://aka.ms/winforms-designer. You can read more about it here: https://devblogs.microsoft.com/visualstudio/dot-net-core-support-in-visual-studio-2019-version-16-3/ Alternatively, create your winforms project targeting the full .NET Framework instead of .NET Core 3.0. – Ed Dore Oct 15 '19 at 17:59
  • @KyleWang, thankyou.. I tried to reset to default settings and also tried shift+f7, but nothing worked . So I moved to visual studio community 2017 – HR20dev Oct 16 '19 at 13:31
  • @EdDore's comment solved my issue. You should create a `Windows Form App (.NET Framework)` instead of a `Windows Form App (.NET Core)` – JVE999 Oct 28 '19 at 18:57

7 Answers7

14

To enable the designer, download and install the Windows Forms .NET Core Designer VSIX package.

See article: https://devblogs.microsoft.com/dotnet/introducing-net-core-windows-forms-designer-preview-1/

Danielle
  • 2,919
  • 2
  • 14
  • 27
  • So at this point it seems you need to have the VS 2019 Preview 16.5. If you have the latest non-Preview (16.4.2 as of today), they say it won't work. – Andrew Dec 20 '19 at 17:25
2

As of version 16.8.0 Preview 2.1 I have found that I have to turn off this setting and restart and add my form. Once added, I can turn it back on, restart and work.

enter image description here

ΩmegaMan
  • 26,526
  • 10
  • 91
  • 107
1

I had the same problem. The following steps helped me

  1. Remove any other classes than the Form class in the yourformname.cs file
  2. Unload the project and right click on the project and choose edit project
  3. Make sure yourformname form has the SubType set to form <SubType>Form</SubType> and save the file
  4. Reload the project
Jeff B
  • 8,123
  • 17
  • 63
  • 134
Andreas
  • 650
  • 6
  • 17
0

This happened to me as well.

I was using the wrong template (.net core when I wanted to use the full .net framework which allows you to edit the form as you were used to in vs 2017 or previous versions).

newbie
  • 1,189
  • 9
  • 22
0

I am using 16.6.5 and it appears after you first created the project, you have to run the project in order for IDE to pickup the form.cs.

Johnny Wu
  • 1,087
  • 11
  • 26
0

Certainly in WinForms one thing to check is you haven't declared any other classes in the form class file before the form itself. The example below will prevent the designer loading the form or even giving you the menu option to 'View Designer'

// Don't do declare a class here
public class MyNewClass
{
}

public partial class MyForm: Form
{
    public MyForm()
    {
        InitializeComponent();
     }
}
Paul Gee
  • 171
  • 1
  • 3
-1

I have tried the suggestion by Danielle, but it appears to be a circular reference to other articles Olia. A plethora of comments also say that what Olia is suggesting, does not work, and at the end, you need to do the following.

Solution

Download Visual Studio 16.6.0 Preview 2.1 from here. This works.

Community
  • 1
  • 1
Farhan
  • 2,489
  • 3
  • 27
  • 50