CheckBox Question

Does anyone know of a way of 'hiding' the focus of a CheckBox's Caption when it's state is changed?

i.e. I want to be able to change the state of the CheckBox, without that causing it's caption to be focused or 'highlighted'.

Cheers, Chris.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.



after changing the state should help.

this is a very simple answer. but it will solve your problem i think.

take a checkbox and clear the caption of the checkbox (resize the checkbox that its width and height is about 17 pixels). then put a label to the right side of the checkbox and put your checkbox text to the caption of the label.

now you'll never see a focus rect. if you the checkbox changing when someone clicks on the caption. then change checkbox state in the onclick of the label.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
she3i3iAuthor Commented:

I do not have an OnClick event for the checkbox. I'm reading its state from somewhere else and do not particularly want to put in an OnClick event just for that. I've used this method before and at the end of a project, code just gets too messy to read.


I have also used this method, and although its alot cleaner, I'm still curious if there is another way to go about it.

Cheers, Chris.
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

simple and effective?

try in form's onshow:

//focus on checkbox's caption
checkbox1.checked := false;


//focus somewhere else
checkbox1.checked := false;

Isn;t this what you want?

You don't need an onclick event for the checkbox if you use a label as suggested by gnom.  Just create an OnClick event for the label that says...

  CheckBox1.Checked:=Not CheckBox1.Checked;

That'll do the trick!

you can make it have a parent that is not enabled, then the CanFocus property
is False
Or use dummy components for the visual effect; without events, and make the real one's invisible; place them on top of each other.

Never mind, it's late here...

How about it? I don't get why your code get's messy by what you want.
she3i3iAuthor Commented:
Although I have used the method before and... by the looks of it... again, I'm giving the points to gnom out of good old sportmanship as it was the closest to what I wanted to do.

Regards, Chris.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.