Disable Designer for a derived class in Visual Studio 2008

久未见 提交于 2021-02-07 07:15:41

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/8088573/disable-designer-for-a-derived-class-in-visual-studio-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!