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.

有帮助吗?

解决方案

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;
        }
    }
}

其他提示

create a new class and inherit class Button, eg

public class OnetsButton : Button
{
    public OnetsButton()
    {
        this.SetStyle(ControlStyles.Selectable, false);
    }
}

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top