Reputation: 171
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
Upvotes: 15
Views: 21348
Reputation: 21
The solution I came up with and that worked for me;
In short: Copy the afflicted forms to a new project and back.
By the way, in my case it happened in VS 2022.
Upvotes: 0
Reputation: 155
Removing inner class makes my form back to Visual Studio Design display.
For example, this Form2 will be regarded as normal class if you uncomment its inner class.
namespace XXX {
//public class EventMsgXXX:EventArgs {
// public string mmm {get; private set;}
// public EventMsgXXX(string str) {
// mmm = str;
// }
//}
public partial class Form2:Form {
public event EventHandler<EventMsgXXX> OnCallback;
public Form2() {
InitializeComponent();
}
private void btn_Click(object sender,EventArgs e) {
EventHandler<EventMsgXXX> handler = OnCallback;
if (handler != null) {
EventMsgXXX arg = new EventMsgXXX("HELLO");
handler(this, arg);
}
}
}
}
Upvotes: 0
Reputation: 201
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();
}
}
Upvotes: 1
Reputation: 31596
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.
Upvotes: 2
Reputation: 674
I had the same problem. The following steps helped me
<SubType>Form</SubType>
and save the fileUpvotes: 2
Reputation: 1518
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.
Upvotes: 0
Reputation: 1217
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).
Upvotes: 0
Reputation: 2575
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.
Download Visual Studio 16.6.0 Preview 2.1 from here. This works.
Upvotes: -1
Reputation: 3839
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/
Upvotes: 14