Question

I have a problem with flickering on my controls. I have Drag and drop operation, and when dragging a control, it is flickering. How can I solve it ? I tried this

 public Form1()
    {
        InitializeComponent();
        .
        .
        .
        this.DoubleBuffered = true;
    }

But did not worked for me. How can I fix it ?

Was it helpful?

Solution

public static void SetDoubleBuffered(System.Windows.Forms.Control c)
{
   //Taxes: Remote Desktop Connection and painting
   //http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx
   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); 
}

This method helps a lot.

was took from here

stackoverflow.com/a/77233/1699916

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top