Change box color on checkbox control

  • Thread starter Thread starter schaefty
  • Start date Start date
S

schaefty

I recently posted this on the incorrect forum, and so I would like to
ask the question here. I did get some good ideas on the other group,
but I have not yet come up with a solution for me. I am using VS2005
(express edition) and coding in vb.net.

I wrote an application that uses 30 checkboxes to set the configuration
of a device. The device is constantly polled, and its response is
decoded and reported in a mirror battery of another set of 30
checkboxes. Therefore, the app is broken down into 1 grouping of
checkboxes that represent your desired state, and another grouping of
checkboxes that reports current actual state (these may differ for
various reasons). I used the checkboxes such that if the box is
checked it represents a true for that state.

It all worked just fine, but the customer freaked out because they kept
wanting to access and click the "current state" group of checkboxes, or
they would simply look at the incorrect group, no matter how I
seperated them into groups on different parts of the app. What they
demanded is to leave the functionality of the checkboxes as is, but to
simply gray the boxes on the "current states" to make them easier to
distinguish.

Therefore, all I want to do is take the little white box on the
checkbox control, and make it slightly gray. I do not want to adjust
the functionality at all. I assume I will have to make a new control
class and inherit the controlbox control and make the modifications
there. I haven't been able to work this out yet. Other options would
be to make a couple of images, one of a grayed box and the other with a
grayed box with a check, and just swap the images as necessary. This
seems more complicated than it should be.

Thanks for any help!

-Rdog
 
GhostInAK said:
Hello (e-mail address removed),

Check out CheckBox.Enabled

-Boo

While that is the look of the box that I want, I still need the text
and the check to be in black. I believe I can still alter the
Checkbox.checked state even if it was disabled, so if you can tell me
how to get the text / check to black?
 
Hello RaoulDuke,

Override the control's paint procedure.

It may be best to just make a new control.

-Boo
 
Yea, I think that I will have to make a new control class and start by
inheriting the standard checkbox control. However, I don't know how to
override the paint procedure...
 
*bounce* Still hoping for some help on this. It seems it is much
harder than it should be. Searching this forum, I see other people
have had the same question in the past, but I haven't really found a
suitable answer.

The one way that almost works is to remove the text associated with the
checkbox and put a label there instead. Then you can set the enabled
property to false which gives the gray look nicely. The only trouble
is the checkmark also becomes grayed out and too difficult to see
properly.

Thoughts?
 
Hello RaoulDuke,

My final thoughts on this:

1. Either implement your own wrapper for the Win32 Common Control (checkbox)..
implementing uxtheme.dll functions for the XP look, etc..

or

2. Derive a new control from checkbox.. (or if its not inheritable, add
hacks to the form code) which makes it so the value can not be changed using
the UI (at runtime).. then just change the checkbox's forecolor.. a nice
bright RED should indicate that these values are not to be touched.. and
the electric cattle prod wired into the user's chair will ensure they get
the message.

-Boo
 
If you don't really need a checkbox but rather something that looks like
one, you might be able to use the ControlPaint class and just draw one in
whatever state you want it it.

/claes
 
Back
Top