Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reset a value in the property page...I hate it!
Message
De
11/09/2004 10:51:59
 
 
À
11/09/2004 10:14:49
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00941301
Message ID:
00941313
Vues:
17
Mike,

If the background color is Blue and you can change it, then there has to be code in the control for this. I guess it's not the Button itself (sorry, I assumed it was just a sub-classed button, but a UserControl with a Button on it). Anyway, I think that probably what happened is that there is code in the Control that sets the Background color to Blue, and since Background color is an existing property of a Control, it shows up in the Property Sheet. Your co-worker however has not set up a default for this property and so it goes back to the original Windows default when you click "Reset". There are ways to set up default values for properties by using the [DefaultValue()] attribute.

However, BackColor is a tricky one. First, I don't think you should be setting button colors ... they should default to what the user has set on his computer for his color preferences. Secondly, I'm having trouble specifiying a default for BackColor ... I can't get it to work. But, for other types of properties, specifying a default works just fine. It would be something like this (note that in my example, I *am* using BackColor, since that's what you asked about ... if you can figure out a way to make the DefaultValue work for this, great. I spent more than a few minutes on it and gave up):
[DefaultValue("System.Drawing.Color.Blue")]
public override System.Drawing.Color BackColor
{
	get {return base.BackColor;}
	set {base.BackColor = value;}
}
Also note that using the above code can cause other problems, as Kevin Goff mentioned in a post about default Font size and having it automatically changed when the base sub-class changes (IOW, you'd need to commment out the "set" in the above code, but then you'd never be able to change it either). I can look up which message/thread that was if you want to see the discussion, but I don't have it off the top of my head.

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform