Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Designer for a derived class in Visual Studio 2008

I have class A derived from a Windows.Form class, using the VS2008 designer. When I double click on the file name in Visual Studio Solution Explorer, the form designer opens. This is the desired behavior.

I have a second class B, derived from A (manually). This class is pure code - it adds some functionality but the form is the same - but if I double click on its file name in Visual Studio Solution Explorer, it opens the form designer. This is the undesired behavior, particularly as I will need to produce similarly derived classes C-Z.

Is there a way of forcing the file to always open in the code editor? I'm aware of two proposed workarounds:

  1. Give class B the attribute: [System.ComponentModel.DesignerCategory("")]

    This appears to have worked in the past according to various postings, but doesn't seem to have any effect in my situation. The VS environment still tries to open a form designer for the class.

  2. Rename the source file to meaningfulname.Designer.cs

    This... well, it just isn't nice, is it?

Should solution (1) still work? If so, what might I be doing wrong?

Or is there another solution?

like image 522
MZB Avatar asked Nov 11 '11 01:11

MZB


1 Answers

Try to use [System.ComponentModel.DesignerCategory("Code")] instead.

like image 133
Edwin de Koning Avatar answered Sep 21 '22 09:09

Edwin de Koning