我怎么能告诉Visual Studio中的设计器代码不填充字段? [英] How can I tell Visual Studio to not populate a field in the designer code?

查看:167
本文介绍了我怎么能告诉Visual Studio中的设计器代码不填充字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的控制,当我拖到窗体,将创建下列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; }

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

< 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆