[C # tips] solve the problem of WinForm control TabControl flashing

Source: Internet
Author: User

When developing a WinForm program using C #, it is often found that TabControl has a serious flickering problem. This is mainly because the TabControl control will draw the default window background during implementation. In fact, the following simple code can effectively alleviate this problem. This is the role of skills. You do not need to understand too much knowledge, but you need to accumulate a lot to get twice the result with half the effort. 1 using System; 2 using System. collections. generic; 3 using System. text; 4 using System. windows. forms; 5 namespace WfGUI. forms 6 {7 /// <summary> 8 // TabContriol 9 that does not flash /// </summary> 10 public class NoFlashTabControl: tabControl11 {12 // <summary> 13 // constructor, set the control style 14 /// </summary> 15 public NewTabControl () 16 {17 SetStyle18 (ControlStyles. allPaintingInWmPaint // draw all messages in the window. 19 | ControlStyles. optimizedDoubleBuffer // use double buffer 20, true ); 21} 22 // <summary> 23 // set the extended style of parameters created in the control window 24 /// </summary> 25 protected override CreateParams CreateParams26 {27 get28 {29 CreateParams cp = base. createParams; 30 cp. exStyle | = 0x02000000; 31 return cp; 32} 33} 34} 35}

Related Article

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.