zoukankan      html  css  js  c++  java
  • C#使用双缓存减少界面闪烁

    场景:一个panel中动态加载多个自定义控件item,类似QQ聊天窗口

    问题:加载panel时界面会卡顿,先显示阴影再显示界面;移动滚动条时item会闪烁

    解决方法:

    panel 添加方法,减少界面闪烁:

    protected override CreateParams CreateParams
    {
        get
        {
             CreateParams cp = base.CreateParams;
             cp.ExStyle |= 0x02000000;
             return cp;
        }  
    }

    item构造函数中添加代码,减少移动滚动条时闪烁:

    //构造函数
    public item()
    {
        SetStyle(
              ControlStyles.AllPaintingInWmPaint |    //不闪烁
              ControlStyles.OptimizedDoubleBuffer    //支持双缓存
        ,true);
        InitializeComponent();
    }

    网络限制不能复制,代码手打的,可能拼写有错

  • 相关阅读:
    了解JVM原理
    封装JS
    “==”和Equals的区别
    SpringMVC请求RequestMapping() 请求乱码
    博客25周
    博客24周
    博客23周
    博客22周
    博客第21周
    博客第21周
  • 原文地址:https://www.cnblogs.com/bincoding/p/7772547.html
Copyright © 2011-2022 走看看