LOGIN    REGISTER    YOUR CART

homepage
VisualHint's blog
2009
May20

A single checkbox for any property…

... or at least for properties that care publishing two standard values.

In the real life, you won’t always have a boolean to represent 2-states variables. Sometimes, you may have an arbitrary type, for example a simple class with two static members (something like Breaker.Opened / Breaker.Closed) or the couple null / anything. Welcome the retouched checkbox inplace control to show this property as a single checkbox. The rule is this: if your property is not a boolean, not an enumeration and not a collection, then the PropertyGrid will check if there is only two standard values (published by a TypeConverter or manually assigned by you). If this is the case, the single checkbox will be used to let the user switch between these values.

In case you are not sure how to do it with your type, there is an example in the updated sample.