为什么我的班级突然多了一个“设计师”?
我刚刚完成添加和删除不同的数据库模型(我试图弄清楚我应该在这个项目中使用哪个模型),然后在玩了一段时间后,我注意到我的一个类的图标与我的 Calculations.cs 旁边显示的图标发生了变化第一个图像中的 Class 为 Balance.cs 图标。
Balance.cs 现在具有此设计器组件,因此当我双击它时,我会看到第二个屏幕截图。这似乎允许我将工具箱中的组件添加到我的类中。我的 Balance.cs 中实际上有两个类。这个 Designer 的东西只影响其中之一/与之交互(它继承自 SerialPort)。
我真的不知道发生了什么变化或我做了什么来实现这一点,而 ctrl+z 则不是成为我在这里的朋友。如何将 Balance.cs 更改回没有设计器组件的常规类?
谢谢
I just finished adding and removing different database models (I was trying to figure out which one I should be using for this project) then after playing around for a while I noticed one of my classes's icon changed from what is shows beside my Calculations.cs class in the first image to the Balance.cs icon.
The Balance.cs now has this Designer component so when I double click on it I see my second screen shot. This seems to be allowing me to add components from the toolbox to my class. There are actually two classes within my Balance.cs. This Designer thing is only affecting/interacting with one of them (it inherits from SerialPort).
I don't really know what changed or what I did to make this happen and ctrl+z is not being my friend here. How do I change Balance.cs back to a regular class with no designer component?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果源文件中的任何类直接或间接继承自
System.ComponentModel.Component
(例如SerialPort
),Visual Studio 将提供设计时支持给你。这有时是不需要的行为,在大多数情况下您可以安全地忽略它。如果它确实困扰您,您可以使用
[DesignerCategory]
属性来装饰您的类(将类别设置为空字符串)。If any of the classes in a source file inherit - either directly or indirectly - from
System.ComponentModel.Component
(such asSerialPort
), Visual Studio will provide design-time support to you. This is sometimes unwanted behaviour, and you can safely ignore it in most cases.If it really bothers you, you can decorate your class with the
[DesignerCategory]
attribute (set the category to an empty string).