Question

I was working on a WinForm, and for an unknow reason, I can't open it in design mode anymore, any (only that specific form). Is there anyway to tell Visual Studio 2013 that it's a WinForm and not a Class ?

enter image description here

Was it helpful?

Solution

You can "unload" the project, and then edit the .csproj file. Search for your .cs file, and insert a SubType node... <Compile Include="Scraper.cs"><SubType>Component</SubType></Compile>. Save the .csproj and Reload your project.

OTHER TIPS

For me I had a class defined before the partial class, i.e.:

public class MyClass { ... }
public partial class MyForm : Form { ... }

Defining MyClass after MyForm fixed the problem.

Same happens to me, when I did some base class for my forms and manually change to it in generated forms.

Solution was to add

[System.ComponentModel.DesignerCategory("Form")]

attribute to base class definition.

P.S.: same way around, you can use

[System.ComponentModel.DesignerCategory("Code")]

if you want some own derived control to never open in designer, like if it is a user conhtrol.

Right-click on your file in Solution Explorer, "Open with.." and reselect the designer in the list. Maybe? Or maybe your Designer.cs file has an issue or was somehow corrupted as mentionned by the replier above.

If you remove the Form inheritance after your form class you experience the behaviour described

 public partial class MyMainForm : Form
 {

 }

here, if you remove the inheritance from the base Form class Visual Studio shows your form code instead of the designer when you double click on the form name in the Solution Explorer

Make sure your namespaces match on the form class StateRuleDetailTriggerForm.cs and its designer class StateRuleDetailTriggerForm.Designer.cs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top