-1

I am trying to avoid flickering when drawing on the Panel. I have found a good solution first to derive a class from Panel class

public class DoubleBufferedPanel : Panel
{
    public DoubleBufferedPanel()
    {
        this.SetStyle(ControlStyles.AllPaintingInWmPaint |
            ControlStyles.OptimizedDoubleBuffer |
            ControlStyles.UserPaint, true);
    }
}

then replacing (which is naturall) System.Windows.Forms.Panel with DoubleBufferedPanel in the Designer.cs class. It works perfectly for me, but it is occupied by being not able to go to the Form1 [Design] due to following error: The service System.Windows.Forms.Design.ISelectionUIService already exists in the service container. Parameter name: serviceType

The error appear even when I just copy - paste the DoubleBufferedPanel class to my Form1.cs System.Windows.Forms.Panel with DoubleBufferedPanel.

Is there any way to avoid such an error? I can deal with it, because my program works perfectly when I run it, but I have no access to the Form1 [Design].

hegendroffer
  • 123
  • 1
  • 13
  • Perhaps there are some issues with directly modifying Designer.cs in such a manner. You may try to create your control in a more standard way https://msdn.microsoft.com/en-us/library/5h0k2e6x(v=vs.100).aspx and, then add it in the designer from the toolbox http://stackoverflow.com/questions/3446429/how-to-put-a-usercontrol-into-visual-studio-toolbox – Eugene Podskal Apr 17 '16 at 10:49

1 Answers1

0

I have found a solution, but it is very strange. I created a new class DoubleBufferedPanel.cs in my Project as separate file and copied pasted code. Now it is working without problems. Topic can be closed, but I have still no idea what has just happend.

Thank You !

hegendroffer
  • 123
  • 1
  • 13