开发者

How can I tell Visual Studio to not populate a field in the designer code?

I have a custom control that when I drag onto the form, creates the following designer.cs code:

// 
// 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开发者_StackOverflow中文版.PropertyChangedEventHandler(this.colorPicke

I'd like it (Visual Studio) to completely ignore the .Color attribute and leave it be. How can I tell it to do that?

Thank you!


You can derive a new class from the ColorPickerBackground class. Override (or new) the Color property and decorate with the attributes found in System.ComponentModel...

Take a look at these:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Color Color { get; set; }

http://msdn.microsoft.com/en-us/library/system.componentmodel.designerserializationvisibilityattribute.aspx

http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.aspx

http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜