[英]How can I create a control with IPAddress properties that can be edited in the designer?
[英]Is there an attribute I can add to a class so it will be edited as code, not in the designer?
我创建了一个继承自UserControl的类,但我只想将其用作子类的基础。 有没有办法阻止VS2008在设计器中编辑它,这不会阻止子类在设计器中被编辑?
有。 我相信如果你在一个文件中有多个类,VS只看第一个,但我可能会弄错。 在任何情况下,这应该做的伎俩:
[System.ComponentModel.DesignerCategory("Code")]
public class SomeBaseClass : UserControl
{
//...
}
请注意,在2017年之前的Visual Studio版本中,您必须使用属性的全名,如上所示。 如果您尝试在其上面放置一个using语句并且只是尝试“DesignerCategory”,那么visual studio可能不会尊重它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.