Is it possible to tell Visual Studio not to treat a source file as a quot;componentquot;?(是否可以告诉 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 不要将源文件视为“组件"?


- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01