问题描述
我正在试图找出如何子类化控件并覆盖一些默认属性。我可以子类化一个控件并添加我自己的新属性并设置它们的默认值。但是如何更改*现有*属性的默认值?
对于自定义属性,我可以这样做:
[DefaultValue (FormatType.Default)]
public FormatType FormatAs
{
get {return this.formatAs; }
set {this.formatAs = value; }
}
但是当我尝试使用现有属性的代码结构时,它不会编译。我错过了什么?
TIA,
Mike Rodriguez
I''m trying to figure out how to subclass a control and override some of the default properties. I can subclass a control and add my own new properties and set their default values. But how do you change the default value for an *existing* property?
For a custom property I can do this:
[DefaultValue(FormatType.Default)]
public FormatType FormatAs
{
get { return this.formatAs; }
set { this.formatAs = value; }
}
But when I try that code structure with an existing property it won''t compile. What am I missing?
TIA,
Mike Rodriguez
推荐答案
这篇关于子类控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!