我怎么能告诉Visual Studio中的设计器代码不填充字段? [英] How can I tell Visual Studio to not populate a field in the designer code?
问题描述
我有一个自定义的控制,当我拖到窗体,将创建下列designer.cs代码:
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.PropertyChangedEventHandler(this.colorPicke
我想它(Visual Studio中)完全忽略。颜色属性,让它可以。我怎么能告诉它这样做呢?
I'd like it (Visual Studio) to completely ignore the .Color attribute and leave it be. How can I tell it to do that?
感谢您!
推荐答案
您可以得到从ColorPickerBackground类的新类。覆盖(或新的)Color属性,并与系统中找到的属性装饰.ComponentModel ...
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...
看看这些:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Color Color { get; set; }
< A HREF =http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.aspx相对=nofollow> http://msdn.microsoft.com/en-us/library/ system.componentmodel.browsableattribute.aspx
的 http://msdn.microsoft.com/en-us/library/system.componentmodel.editorbrowsableattribute.aspx
这篇关于我怎么能告诉Visual Studio中的设计器代码不填充字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!