简体   繁体   中英

C# winform button inside border after click

I have been spending over 2 hours to try fix this but I can't, really angry and stress with this.

在此处输入图片说明

You can easily seen the black border insde Sign in button, it's show when I click.

I have googled plenty of times but I can't fix that.

Some one told me do that, not working.

public class MyButton : Button
{
    public override void NotifyDefault(bool value)
    {
        base.NotifyDefault(false);
    }
}

I've done this too but get nothing: C# WinForms - custom button unwanted border when form unselected

That rectangle indicates that your Button has focus. It doesn't make too much sense to hide it; however, it is possible to do so:

public class MyButton : Button
{
    protected override bool ShowFocusCues
    {
        get { return false; }
    }
}

I have found solutions, this really simple and this answer for who have similar question.

Problem is button focus, to handle this, simplest way is

private void Form1_Load(object sender, EventArgs e)
{
    this.Select();
}

Thanks everybody for helping me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM