title: Flickering while Drawing Mouse on MouseMove
body: <p>Using GDI+ and C#, I am trying to Draw a Rectangle with my Mouse Movement on a Panel (called DrawingPanel), I am using Double buffered as well I am doing the drawing in Paint Event, Still It is causing a Lots of flickering when my Mouse is Moving.</p>
  
  <p>Here is my Code...</p>
  
  <pre><code>Rectangle mRect = new Rectangle();
  Boolean isDragging = false;
  
  public Form1()
  {
     InitializeComponent();
     this.DrawingPanel.Paint += new PaintEventHandler(this.OnPanelPaint);
     this.DrawingPanel.MouseMove += new MouseEventHandler(this.OnPanelMouseMove);
     this.DrawingPanel.MouseDown += new MouseEventHandler(this.OnPanelMouseDown);
     this.DrawingPanel.MouseUp += new MouseEventHandler(this.OnPanelMouseUp);
     this.DoubleBuffered = true;
  }
  
  private void OnPanelPaint(object sender, PaintEventArgs e)
  {
     using (Graphics g = this.DrawingPanel.CreateGraphics()) 
     {
        g.DrawRectangle(Pens.Black, mRect);
        g.FillRectangle(Brushes.SkyBlue, mRect);
     }
  }
  
  
  private void OnPanelMouseMove(object sender, MouseEventArgs e)
  {
      if(isDragging)
      {
        mRect = new Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top);
        this.DrawingPanel.Invalidate();
      }
  }
  
  private void OnPanelMouseDown(object sender, MouseEventArgs e)
  {
      mRect = new Rectangle(e.Location, new Size(0, 0));
      this.DrawingPanel.Invalidate();
      isDragging = true;
  }
  
  private void OnPanelMouseUp(object sender, MouseEventArgs e)
  {
      isDragging = false;
  }
  </code></pre>
  
  <p>Any Idea why it is happening still ? </p>