I don't want the button I add to have dotted borders when clicked, so I found out that I can disable that by turning off the focus cues. I don't want to have to change settings like this for each individual button I add. Is there any way to set property defaults in Visual Studio?
Asked
Active
Viewed 387 times
0
-
possible duplicate of [Hiding dashed outline around trackbar control when selected](http://stackoverflow.com/questions/1484270/hiding-dashed-outline-around-trackbar-control-when-selected) – DaveShaw Dec 18 '11 at 22:40
-
@DaveShaw: it is related, but not duplicated... – Matthias Dec 18 '11 at 22:52
-
@MatthiasKoch - good point, posted an answer with how to implement. – DaveShaw Dec 18 '11 at 23:00
-
Possible duplicate: [How to set/change/remove focus style on a Button in C#?](http://stackoverflow.com/questions/148729/how-to-set-change-remove-focus-style-on-a-button-in-c) – Gert Arnold Dec 19 '11 at 08:54
1 Answers
0
What you need to do is create a new Control based on Button
and use it throughout your application.
public class MyButton : System.Windows.Forms.Button
{
protected override bool ShowFocusCues
{
get { return false; }
}
}

DaveShaw
- 52,123
- 16
- 112
- 141
-
1Although it is a solution, it is not an answer to the question. This would also force him to replace all present buttons with the new MyButton class. – Matthias Dec 18 '11 at 23:08
-
I don't think it's possible any other way. A quick peek with ILSpy at the code inside ShowFocusCues doesn't render anything that can be set. – DaveShaw Dec 18 '11 at 23:16