我有一个自定义控件,当我拖到窗体上时,会创建以下designer.cs代码:
//
// colorPickerBackground
//
this.colorPickerBackground.Color = Color.Empty;
this.colorPickerBackground.Location = new System.Drawing.Point(256, 175);
this.colorPickerBackground.Name = "colorPickerBackground";
this.colorPickerBackground.Size = new System.Drawing.Size(156, 21);
this.colorPickerBackground.TabIndex = 17;
this.colorPickerBackground.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.colorPicke
我希望它(Visual Studio)完全忽略.Color属性并保留它。我怎么能告诉它呢?
谢谢!
答案 0 :(得分:3)
您可以从ColorPickerBackground类派生一个新类。覆盖(或新增)Color属性,并使用System.ComponentModel ...
中的属性进行修饰看看这些:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Color Color { get; set; }
http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.aspx
http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx