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 不要将源文件视为“组件"?
基础教程推荐
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 将数据集转换为列表 2022-01-01
