4

Possible Duplicate:
How to set/change/remove focus style on a Button in C#?

Is there a way to remove the blue outlining when a button is pressed/was pressed/is active?

Here is a screenshot:

Blue outlining

Is there any way to hide it? I am using C# and winforms.

Community
  • 1
  • 1
Tim Kathete Stadler
  • 1,067
  • 4
  • 26
  • 52
  • im pretty sure there is a .IsActive or .IsSelected attribute you could probably set to false –  Jan 16 '13 at 09:27
  • If you're wanting to hide the "focus" style, you're probably not too worried about accessibility requirements, and thus not concerned about keyboard compatibility. You could instead have a panel or other control with custom painting and response to the `OnClick` event. – Snixtor Jan 16 '13 at 09:33

3 Answers3

3

Amalgamating the answers from the duplicate question

public class NoFocusCueButton : Button
{
    public NoFocusCueButton() : base()
    {
        InitializeComponent();

        this.SetStyle(ControlStyles.Selectable, false);
    }

    protected override bool ShowFocusCues
    {
        get
        {
           return false;
        }
    }
}
Jodrell
  • 34,946
  • 5
  • 87
  • 124
1

create a new class and inherit class Button, eg

public class OnetsButton : Button
{
    public OnetsButton()
    {
        this.SetStyle(ControlStyles.Selectable, false);
    }
}
John Woo
  • 258,903
  • 69
  • 498
  • 492
1

I have a solution now, it's not very sexy, but it works. I just added an invisible button to the form and now everytime a button is clicked, I select the invisible button. Works for me.

Tim Kathete Stadler
  • 1,067
  • 4
  • 26
  • 52