[ACCEPTED]-Disable designer in Visual Studio?-windows-forms-designer

Accepted answer
Score: 102

Add a [System.ComponentModel.DesignerCategory("")] attribute before a UI class to avoid 6 designer activation on double-click.

Note 5 that including System.ComponentModel at the top of the file and 4 then just adding the attribute as [DesignerCategory("")] will 3 not work (at least not in Visual Studio 2 2010/2013). You must use the full, namespace-qualified 1 attribute type name.

Score: 29

Right clicking on a project file and selecting 2 open with allows you to set the defaults 1 for opening file types.

Score: 7

Actually, all you have to do in VS2010 is 5 right click the .cs file that you don't want 4 to open in the designer, select the "Open 3 With.." option, then make CSharp Editor 2 the default. Notice that the form view is 1 the default before you change it.

Score: 2

Just dont add "new form" , add to the project new class and 1 inherit him from the Form class.

Score: 2

Frederik, sure you're right, but not in 38 one fact. ( this one I.J wanted to know 37 ) As soon as you inherit from any Component, the 36 studio tries to open it in a designer editor. That 35 is a default behaviour of the visual studio.

If 34 you double click a file in the solution 33 explorer, then a designer opens. So it's 32 really annoying if you always get such strange 31 designer for classes that are just inherited 30 from a Component, but do not contain any 29 visible things.

The only thing that really 28 helped me out, was to set this attribute:[System.ComponentModel.DesignerCategory("")]

I 27 didn't knew this =) so cool hint !

I just 26 get a problem with partial MainForm classes. Then 25 it yells "duplicate attribute"...

Does 24 here anybody knows a solution to avoid in 23 some partial class-files the designer to 22 be opened on double click ( without the 21 duplicate attribute error on compile ? )


I 20 think I found a small bug, in VS2005... By 19 setting the DesignerCategory-Attribute on 18 the partial form class, on save the solution 17 explorer shows up an icon, identifying the 16 file as a c# file (no form).

Then I put a 15 comment (//) before the attribute - and 14 it keeps opening the file in code view. Also 13 after closing and reopening it's stored 12 internally as a non designable form-part. Even 11 on re opening the complete solution.

So I 10 think there is any information in the solution 9 or project file...

... I found this in the 8 .csproj file: ...

<Compile Include="GUI\VFormMain_Test.cs">
</Compile>
<Compile Include="GUI\VFormMain_Theme.cs">
</Compile>
<Compile Include="Core\VTTEnv.cs" />
<Compile Include="GUI\VFormMain.cs">
  <SubType>form</SubType>
</Compile>

...

Studio updates from 7 time to time - then it updated the form 6 files again (doh)... ok.. but there is probably 5 a workaround to avoid this.


snip... last 4 edit... found something:

http://social.msdn.microsoft.com/Forums/en-US/csharpide/thread/64c77755-b0c1-4447-8ac9-b5a63a681b78

( name the file 3 you want to open without designer into .Designer.cs 2 )

( Yes you have to name something to switch 1 it of LOL ) Seems to work.

Score: 0

If you don't want to use the designer, then 8 don't use it ?

You can create a new form 7 from scratch, without the designer generating 6 any code by creating a new empty class, and 5 let the class inherit from System.Windows.Forms.Form

Then, VS.NET 4 will probably still indicate that your class 3 is a Form, and you can still open it up 2 in the designer if you want. (And drop 1 controls on it).

More Related questions