Skip to content

Instantly share code, notes, and snippets.

@jayu108
Last active September 23, 2020 02:34
Show Gist options
  • Save jayu108/282fad0c94aad8c775b9d9923fa8a2ad to your computer and use it in GitHub Desktop.
Save jayu108/282fad0c94aad8c775b9d9923fa8a2ad to your computer and use it in GitHub Desktop.
C# -- listview, panel 에서 double buffered, ResizeRedraw Extension 사용한 example code ( Reflection 이용)
using System.Reflection; // 반드시 필요함.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.listView1.DoubleBuffered(true); // DoubleBuffered Extension 사용
this.drawingPanel.ResizeRedraw(true); // ResizeRedraw Extension 사용
}
}
public static class Extensions
{
public static void ResizeRedraw(this Control control, bool enabled)
{
var prop = control.GetType().GetProperty("ResizeRedraw", BindingFlags.Instance | BindingFlags.NonPublic);
prop.SetValue(control, enabled, null);
}
public static void DoubleBuffered(this Control control, bool enabled)
{
var prop = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
prop.SetValue(control, enabled, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment