Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio forms designer

I have an annoying problem. Sometimes Visual Studio does not show option "View designer" for some of my forms in solution explorer. It does not show design mode errors, just doesn't show option to use the designer. I cannot figure out exact cases when this happens.. Does anybody have some ideas about what causes such behavior of solution explorer?

like image 931
ironic Avatar asked Dec 28 '09 16:12

ironic


2 Answers

This will occur if the first class in the source file is NOT the "partial class" for your form. In this case the file type icon in solution explorer will initially display as a form but VS will change it to the "C#" code icon after it has loaded the file and also remove the "View Designer" option from the popup menu. At least in VS2015 this can be fixed by commenting out the offending code and saving the file at which time VS will restore the expected form icon.

like image 144
eric gilbertson Avatar answered Sep 28 '22 10:09

eric gilbertson


I've had this problem too, i've modified the .csproj file to fix it. In my .csproj file i modified this line of code:

<Compile Include="FormName.cs" />

With this code:

<Compile Include="FormName.cs">
    <SubType>Form</SubType>
</Compile>
like image 33
Alessandro Perfetti Avatar answered Sep 28 '22 10:09

Alessandro Perfetti