Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove button border on tab c# winforms

I have a button on my form that has flat style applied and uses a background image, I have removed all borders from the button, but when I tab onto the button from another control a black border appears around the button.

This can be seen in the image below. On the left is the button with black border on the right is a different button but shows how the cancel button should look.

Buttons

like image 585
shane12195 Avatar asked Apr 01 '12 17:04

shane12195


2 Answers

You have to make a new button class using IButtonControl and change NotifyDefault to false:

base.NotifyDefault(false);
like image 43
Saeid Yazdani Avatar answered Sep 23 '22 04:09

Saeid Yazdani


I do not get this border, if I set the BoderSize to 0 in the FlatAppearance section.


Further investigation shows that this border appears only when the button is the default button. You can create your own button, which does never show this border like this

public class NoNotifyButton: System.Windows.Forms.Button
{
    public override void NotifyDefault(bool value)
    {
    }
}

Note: NotifyDefault remains intentionally empty.

like image 102
Olivier Jacot-Descombes Avatar answered Sep 25 '22 04:09

Olivier Jacot-Descombes