Rookie Peck: WinForm How to Implement button buttons without a focus frame

Source: Internet
Author: User

when we set the button to the following properties, there is always a focus frame that bothers us .

Button1. FlatStyle = FlatStyle.Flat;

The effect we want is this:

but when using the Tab Toggles focus when the button gets the focus, it looks like this.

What the hell is this black box ? Now let's talk about how to get rid of this focus frame .

Method One :

someone must want to use a label Ah, of course , the label is OK, but it is not a button, some effects have to write their own ....

FA II:

1. creating a new custom control

2. Code

public partial class btnnoborder:button{///<summary>///construction//</summary>public Btnnoborder () {   InitializeComponent ();} <summary>///Redraw///</summary>///<param name= "PE" ></param>protected override void OnPaint ( PaintEventArgs pe) {     base. OnPaint (PE);} <summary>///Cancel Focus box//</summary>protected override bool showfocuscues{  get    {       return false;}}}    

  

That's it, you can drag the button from the toolbox when you use it.

Specifically, how to add this control to the Toolbox does not introduce

Bye!

Rookie Peck: WinForm How to Implement button buttons without a focus frame

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.