C# 利用反射机制开启控件双缓存

/// <summary>
/// 设置控件的双缓存
/// </summary>
/// <param name="c">所需设置双缓存的控件或窗体</param>
public static void SetDoubleBuffered(this Control c)
{
    //Taxes: Remote Desktop Connection and painting
    if (System.Windows.Forms.SystemInformation.TerminalServerSession)
        return;

    System.Reflection.PropertyInfo aProp =
        typeof(System.Windows.Forms.Control).GetProperty(
            "DoubleBuffered",
            System.Reflection.BindingFlags.NonPublic |
            System.Reflection.BindingFlags.Instance);

    aProp?.SetValue(c, true, null);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章