System.Windows.Forms.Control のダブルバッファリングをさくっと有効にする

リストビューなどのダブルバッファを有効にするには Control.DoubleBuffered プロパティを true にすれば良いのですが、このメンバは protected なので、正攻法でアクセスしようとするとサブクラスを新しく作らなければなりません。

これが意外と面倒なので、以下のような関数で有効にしてしまったほうが手っ取り早いです。

public static void EnableDoubleBuffer(Control c)
{
	PropertyInfo prop = c.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
	prop.SetValue(c, true, null);
}