Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Defaulting Properties
Message
From
18/01/2007 10:57:12
 
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01186613
Message ID:
01186673
Views:
11
>He-he. I think you need to mark your post as an answer again <g>

LOL! Yeah, I guess I do need to do that. <g>

(Note that I did NOT post a question and an answer JUST to get stars!!!! <g>)

~~Bonnie



>
>>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
Reply
Map
View

Click here to load this message in the networking platform