Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-04-24
3
Medium Priority
?
219 Views
Last Modified: 2014-04-29
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?
0
Comment
Question by:bgraves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1500 total points
ID: 40021718
Experience from older technologies, such as VB6, do not translate well to .NET. Take the time to read the documentation: Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method.

Select won't give you the small dashed box around the text in the button, but will at least give you the border around the button itself. The dashed box seems to be directly associated with the keyboard, and unfortunately, I have not found a way to force it through code. Even commands that simulate the keyboard such as SendKeys are useless for that purpose.

One thing you could do if you really attract the attention to the button when after a Select is to change its color on the Enter event, and bring it back to default on the Leave event.
0
 

Author Comment

by:bgraves
ID: 40021733
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?
0
 

Author Closing Comment

by:bgraves
ID: 40029915
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!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question