tags:

views:

179

answers:

1

I'm trying to find out how to make the appearance of a check box look like it does when you hover a mouse over it. I have a group of check boxes without labels and I want to indicate focus this way. I'm currently drawing a focus rectangle around them and it works fine but I'd like to try it this way instead.

I know I can paint it myself but I figure it's being done already so I'd rather take advantage of that if possible.

A: 

You can use either the CheckBoxRenderer (if your application is using visual styles) or ControlPaint.DrawCheckBox (if you are not using visual styles).

If you want to use visual styles, but your end users may have visual styles or not, or if they will ever run the application while connected through remote desktop (which is likely), you will need to check the VisualStyleRenderer.IsSupported static property to determine which method to use; trying to use VisualStyleRenderer (from which CheckBoxRenderer descends) while visual styles are not supported will result in an exception.