Possible Duplicate:
Is there an attribute I can add to a class so it will be edited as code, not in the designer?
Class with System.ComponentModel.Component
on their inheritance path are automatically treated as "components" within Visual Studio (2008), triggering a different icon for the source file:
While the icon does not really matter, the changed double click behavior is really annoying: instead of opening the source code in the text editor, Visual Studio now shows a screen encouraging me to add components to my class by dragging them "from the Toolbox". I do not want to do that!
I am aware that I can right click the source file and choose "View Code", but whenever I forget to do this, I am stuck waiting for a dialog which is absolutely useless. Is there any way to disable the component behavior (preferably in the source code)?
The Open source files in Visual Studio Code experiment allows you to use Microsoft Edge DevTools, but then edit your files in Visual Studio Code instead of in the code editor of the DevTools Sources tool.
Can't you use the DesignerCategory
attribute to decorate your class ?
When decorating your class with this attribute like displayed below, the file should open in 'code view' when you double click it:
[System.ComponentModel.DesignerCategory("Code")] public class MyComponent { }
As OregonGhost already mentioned in his comment this also happens if you make a partial class file from a form.
The problem is even more worse. If you take a look into your project file you can find entries for every file include like this:
<Compile Include="FormMain.cs"> <SubType>Form</SubType> </Compile>
So the solution should be to delete the line <SubType>...</SubType>
cause it seems to be the root of all the problems. But if you delete this line, save the file, open it in Visual Studio, save it again and take a look again into, the line will reappear!
There seems to be only one hard-coded exception within Visual Studio and this is *.Designer.cs. So there is no solution to accomplish this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With