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);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章