Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove dotted line on button

Tags:

c#

winforms

How do you remove the dotted line that appears on buttons when they are selected (either via tab or by clicking them)?

This question is for winforms - any help is appreciated.

enter image description here

Edit: I apologize for the duplicate question. I did search for an answer, but I did not know this issue was due to the 'focus' of the button. As I result I was not finding the appropriate answers.

like image 950
Mike Baxter Avatar asked Mar 28 '13 13:03

Mike Baxter


People also ask

How do I get rid of the dotted border?

Removing Dotted Lines Border Select the cells from which you want to remove the dotted border. Click the Home tab. In the Font group, click on the 'Border' drop-down. In the border options that appear, click on 'No Border'

How do I get rid of the dotted line in HTML?

We can remove the default behavior of hyperlinks which is to show a dotted outline around themselves when active or focused by declaring CSS outline property on active/focused links to be none.

How do I get rid of the dotted line in Indesign?

Those dotted borders normally indicate that those objects are on the master page, and you are seeing them on a body page. Try View > Extras > Hide Frame Edges.


2 Answers

This happens because your Button gains focus. It is possible to remove it but that means giving the focus to something else when your button's focus Enter event is triggered.

private void button1_Enter(object sender, EventArgs e)
{
    // give focus to something else
}

The problem with that is that you lose the ability to use the keyboard in order to select the button (using tab).

Moreover, a more correct approach would be to give focus to the last control that had focus instead of passing it fixed one.

like image 120
coolmine Avatar answered Sep 18 '22 06:09

coolmine


have you tried to remove the focus from the button.

just call Focus(); when the button is clicked.

like image 39
Nicolas Tyler Avatar answered Sep 18 '22 06:09

Nicolas Tyler