是否可以告诉 Visual Studio 不要将源文件视为“组件"?

Is it possible to tell Visual Studio not to treat a source file as a quot;componentquot;?(是否可以告诉 Visual Studio 不要将源文件视为“组件?)

本文介绍了是否可以告诉 Visual Studio 不要将源文件视为“组件"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

可能重复:

虽然图标并不重要,但更改后的双击行为确实很烦人:Visual Studio 现在不是在文本编辑器中打开源代码,而是显示一个屏幕,鼓励我通过拖动组件来将组件添加到我的类中从工具箱".我不想那样做!

我知道我可以右键单击源文件并选择查看代码",但是每当我忘记执行此操作时,我都会等待一个完全没用的对话框.有什么办法可以禁用组件的行为(最好在源码中)?

解决方案

你不能使用 DesignerCategory 属性来装饰你的类吗?

当你用这个属性装饰你的类时,当你双击它时,文件应该在代码视图"中打开:

[System.ComponentModel.DesignerCategory("Code")]公共类 MyComponent{}

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)?

解决方案

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
{
}

这篇关于是否可以告诉 Visual Studio 不要将源文件视为“组件"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:是否可以告诉 Visual Studio 不要将源文件视为“组件"?

基础教程推荐