Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Defaulting Properties
Message
From
18/01/2007 10:40:06
 
 
To
18/01/2007 09:45:19
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01186613
Message ID:
01186656
Views:
16
This message has been marked as the solution to the initial question of the thread.
Argggh! I'm an idiot ... I answered this very question in a post from last year: Message #1137743 I need to use "new" instead of "override".

Nevermind ... =0)

~~Bonnie


>Hi gang,
>
>I know that in my sub-classes for controls such as TextBoxes, I can avoid having the IDE stick extra code in the "IDE-generated" code for properties by setting a DefaultValue in the TextBox sub-class. Like this:
>
>public class MyTextBox : TextBox
>{
>    private string m_MyProperty;
>
>    public MyTextBox
>    {
>        this.m_MyProperty = "";
>    }
>
>    [DefaultValue("")]
>    public string MyProperty
>    {
>        get {return this.m_MyProperty;}
>        set {this.m_MyProperty = value;}
>    }
>    [DefaultValue(typeof(Color), "Window")]
>    public override Color BackColor
>    {
>        get {return base.BackColor;}
>        set {base.BackColor = value;}
>    }
>    [DefaultValue(typeof(Color), "WindowText")]
>    public override Color ForeColor
>    {
>        get {return base.ForeColor;}
>        set {base.ForeColor= value;}
>    }
>}
>
>Note that the BackColor and ForeColor properties are overridden. This all works just fine, but where I'm having a problem is with some of the properties in ComboBoxes that are not virtual properties and therefore cannot be overridden ... such as the DropDownStyle, DropDownWidth and several others. Does anybody know how to set up a DefaultValue for these?
>
>TIA,
>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform