views:

56

answers:

1

Hi,

I'm using a checkbox on a winform app. If you mouseover the checkbox an orange highlight appears showing that that control has the focus. If you tab to that control this doesn't happen though the 'Enter' event is fired. My question is, how do I manually set that orange highlight on the checkbox when it has focus, is it a style attribute?

Thanks, R.

A: 

My understanding is that this cannot be done via the CheckBox control's properties in C#. The behavior you see is how the control is designed: that's what the checkbox does when the mouse cursor is over it, which is not the same as it having the focus.

Your best bet would be to try to send the CheckBox control the right Windows Message via Win32 interop -- although truthfully it may prove challenging to do even via Win32 calls, since there doesn't appear to be a windows message that will easily create the behavior you want.

It's possible you could fake the control into thinking that the mouse is over it, but I'm not sure it's worth the effort for a visual effect that's probably not essential.

Nonetheless, you could take a look at the:

And there's plenty of questions about using SendMessage on SO.

Sorry I couldn't offer a working solution, but maybe a Win32 ninja will swoop in and correct me.

Matt