How to make a UserControl with a custom DefaultBackColor?
Posted
by Blorgbeard
on Stack Overflow
See other posts from Stack Overflow
or by Blorgbeard
Published on 2009-07-27T10:53:38Z
Indexed on
2010/05/04
1:18 UTC
Read the original article
Hit count: 404
When I right-click on my custom UserControl's BackColor
property in the property-grid, then click Reset, I would like the BackColor
property to change to (for example) Color.LightGreen
, and the property value to appear un-bolded, to indicate that it is the default value.
Currently, I know I can do this:
public override void ResetBackColor() {
BackColor = Color.LightGreen;
}
Which works as far as setting it to LightGreen on reset. But it still appears bolded in the property-grid, indicating that the current value is not the default.
I notice that the Control
class has a static read-only property, DefaultBackColor
. Unfortunately, since it's static, I cannot override it.
Is there some way to get all the functionality I want?
© Stack Overflow or respective owner