Link to home
Start Free TrialLog in
Avatar of bgraves
bgravesFlag for United States of America

asked on

.Net Focused control has box when tabbed to, but not on cnt.focus()

I have several buttons on a form. If I tab to a button, there is a small box around the text. The box will then move with arrows, tabs or any calls to cnt.focus().

If I never tab to any buttons, I will not have the small box and arrows will not cause it to show, cnt.focus() will not cause it to show either.

I am using a flat style for the buttons with everything set to transparent, and the FlatAppearence.BorderSize=0. I am just changing the colors as the mouse enters/leaves the button's area. However with the tab, one can still see which button will be activated by [ENTER]; without the tab, the one cannot see, since all the buttons have the same color after the mouse exit (I do want that).

How do I cause the system to draw that box around the control that shows it has the focus just like the system does when I tab to the control?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bgraves

ASKER

Yes, of course, .focus or .select make no difference to the issue at hand.
I am, in fact, already changing the color on enter and restoring it on exit. BUT that is where the problem comes in. After exit, all the buttons look the same - however, windows knows that one of them is "selected" and if you were to press ENTER, that one will execute. The user, though, cannot see which button has this "magical" property. If he presses an arrow key, he can figure it out because the next button in sequence will get the color (so it must have been the previous one that was active). I should mention I do the same actions for enter/mouseEnter, leave, mouseLeave.

Again the problem is to show which button is the "selected" one. The dashed box is the perfect answer but, of course, it only shows when the TAB is pressed on the keyboard. I could introduce yet a third visual clue (color, background, etc.) but why not use the same method as Windows?

Does anyone know how to make the dashed box appear?
Avatar of bgraves

ASKER

There isn't a real solution to my problem, apparently. I assign a grade of B because its not a solution but certainly deserves recognition because he shows that there isn't a solution!