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 不要将源文件视为“组件"?
基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01