I am attempting to create a Windows Forms app in C# in Visual Studio.
Normally one can double click the Form1.cs file in the Solution Explorer in order to access the simple drag and drop designer.
Unfortunately, it only opens up the code for the file.
31.5k 8 8 gold badges 47 47 silver badges 68 68 bronze badges asked Nov 26, 2018 at 19:26 SwingingChad SwingingChad 161 1 1 gold badge 1 1 silver badge 7 7 bronze badges
Probably there was some error when creating the project or you selected and incorrect type of project. Try by clicking "Add New Item" and choose a new Windows Form element. Probably you would need to change the startup class under Program.cs for the program to launch.
Commented Nov 26, 2018 at 19:32Try right clicking the designer file and see if you can find the designer in the "Open With" option list.
Commented Nov 26, 2018 at 19:32@ThomasWeller If that is the case, then it would probably be easier to recreate the original project, as little has been done thus far. I will do that, and update if issues persist.
Commented Nov 26, 2018 at 19:42Have the same issue when placing another class before the form class (in this case my ImageContainer class).
namespace ImageProcessor < internal class ImageContainer < >public partial class Form1 : Form < private ImageContainer m_img = null; >>
By just moving the internal class ImageContainer after the public partial class Form1 : Form < >the VS2019 drag&drop designer could load my Form1 class.
namespace ImageProcessor < public partial class Form1 : Form < private ImageContainer m_img = null; >internal class ImageContainer < >>
Also symbol in Solution Explorer changed back to a dialog icon.
answered Nov 27, 2020 at 12:10 165 2 2 silver badges 10 10 bronze badges Good catch. Really pisses me off that this is a thing. Commented Sep 13, 2021 at 10:42 Also valid for VS 2022. Thanks! Commented Mar 30, 2023 at 0:52 It works. 牛逼 to you! Commented Dec 13, 2023 at 5:28You are in the Folder view.
Change to the Solution (Project) view.
This icon at the top of Solution Explorer.
answered Nov 26, 2018 at 19:35 8,525 14 14 gold badges 79 79 silver badges 106 106 bronze badges How do I switch between the two? Commented Nov 26, 2018 at 19:46 do you have solution file there, just click on it. If you don't have .sln, the press on .csproj Commented Nov 26, 2018 at 19:50When clicking on the icon, it says that there is no solution found. There is no .sln file in the explorer, though there is a .csproj file. Clicking on that does not yield any different results.
Commented Nov 26, 2018 at 19:52 close VS and click on project file from Windows Explorer Commented Nov 26, 2018 at 20:05 or from VS: File -> Open -> Project/Solution Commented Nov 26, 2018 at 20:07There is a very simple solution in Visual Studio 2022. If the design view of say form1 is not open, go into the Form1.cs and find the "InitializeComponent();" (see the picture). You can either right click on it, a drop down list will appear, select "View Designer". You could also just place the mouse over the line and press the keys "Shift" and "F7" at the same time. Either way, the design view will open.
answered Mar 3 at 14:37 user22987791 user22987791 41 2 2 bronze badgesThe associations between the files must have gotten broken somehow. You can manually edit the .csproj file and correct it. Search for Form1 . You should have entries for each file that look something like this:
Form Form1.cs Form1.cs
Notice the SubType and DependentUpon . Those are the important pieces.
answered Nov 26, 2018 at 19:33 Gabriel Luci Gabriel Luci 40.3k 4 4 gold badges 62 62 silver badges 93 93 bronze badgesthis made the form design view appear for me, but then I couldn't compile. Something about 'duplicate compile items. '
Commented Mar 18, 2023 at 21:06In my case right-click on Form1.cs (with correct Form icon) and select "View Designer" still showing code.
I found this thread and realized I accidentally choose .Net Core instead of .NET Framework when creating new project:
I should able see this long xml inside .csproj file (.NET Framework) of Solution Explorer panel, which the TargetFrameworkVersion showing v :
. WinExe HelloWorld HelloWorld v4.7.2 .
, instead of short xml below (*.Net Core), which the TargetFramework showing netcoreapp :
WinExe netcoreapp3.1 true
To check project type, can refer this answer.
Microsoft devlogs stated that Designer with .Net Core is not shipped by default yet:
answered Jan 30, 2020 at 18:53 7,723 4 4 gold badges 57 57 silver badges 73 73 bronze badgesIf you want to work with .NET Core project, don’t forget to install the .NET Core Windows Forms Designer, since it isn’t yet shipped inside Visual Studio by default. See the previous “Enabling the designer” section.
Click on the highlighted icon in the below image. It is the Solutions and Folders Icon which will take you back to solution view.
answered Nov 26, 2018 at 19:39 1,963 1 1 gold badge 16 16 silver badges 21 21 bronze badges@ColinG , from what i can tell from your image, is that the solution file is not existing. The Solutions and Folders is not able to locate the solution. For now close the Visual Studio and open it by clicking on the Project and once the Visual studio is open click save. It will again create Solution file
Commented Nov 26, 2018 at 19:57 That did not fix the problem, though I will attempt that solution again when I can. Commented Nov 26, 2018 at 20:11what i mean to say is close visual studio and double click the project file, in your case it is UserInterface.csproj file.
Commented Nov 26, 2018 at 20:13 Open the project from the Explorer. Check the added image Commented Nov 26, 2018 at 20:16Somehow the .resx file got corrupted, i fixed that by copying this same file from my other form. Just delete the corrupt one, paste it, and change the name
answered Sep 22, 2021 at 20:23 Marcelo Mamedes Marcelo Mamedes 11 1 1 bronze badgeAnother possibility is that your form class is missing a SubType subelement in its xml element in the csproj.
For example, here is one that does have the needed subelement:
Form
answered Jan 26, 2022 at 5:58
11 1 1 bronze badge
Right-click on Form1.cs
Select Open With option
From the Open With option, choose "CSharp Form Editor (Default) Click OK
In VS2019 just delete the first project and recreate another one. It will fix the problem of viewing designer page. Now you are able to view your designer.
answered Feb 1, 2020 at 17:37 93 2 2 silver badges 9 9 bronze badgesFound this solution somewhere else:
I've just had similar problem in Visual Studio 2017. On a "Form1.cs [Design]" there was an error shown and I closed it. Then I noticed Form1.cs had no "View Designer" option (also the icon changed to that of a regular class). Luckily, I figured out what the error was: I'd put a class other than public partial class Form1 as a first class in a Form1.cs file. Fixing that caused the icon to change and reenabled the "View Designer" option.
That's a pity those kind of errors doesn't show on the Error List. My error was easy to spot, but I see how this can be a problem, especially on bigger projects.