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 11:13:47
 
 
À
11/09/2004 11:05:06
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00941301
Message ID:
00941320
Vues:
19
Mike,

>In a nutshell, you are saying that it is possible for the "Reset" to put the class's property value back to it original value?

Yep, that's what I'm saying, more or less (although, like I also indicated, it's typically not best-practices to change colors of things like buttons but to instead leave them as Windows defaults).

Also, the other issue of what happens when the BackColor in the base class gets changed to something else other than Blue ... does this change get properly inherited by forms that have used that control? Here's the message I was referring to earlier from Kevin Goff, that explains what I'm talking about: Message #939577

~~Bonnie


>Thanks for the explaination. It's really not making too much sense to me right now. I'll have my co-worker investigate your comments and see if what you are saying sheds some light on the issue.
>
>In a nutshell, you are saying that it is possible for the "Reset" to put the class's property value back to it original value? Eg. the button class's background color is designed as Blue. I use that button on a form and set its background color to Red via the property page. I then run the form and see a Red button. Next, I change my mind and want the default button background color so I right click on the property, select Reset and it should be now Blue. Do I have that correct? That's the behavior I am looking for (just like VFP).
>
>
>Mike
>
>
>>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
Répondre
Fil
Voir

Click here to load this message in the networking platform