private Point downPoint;
        private Rectangle downRectangle;
        private Rectangle lastRectangle;
        private void panelMain_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            downPoint = e.Location;
            downRectangle = new Rectangle(0, 0, ((Control)sender).Width, control.Height);
            downRectangle.Offset(((Control)sender).PointToScreen(new Point(0, 0)));
            ControlPaint.DrawReversibleFrame(downRectangle, Color.White, FrameStyle.Thick);
            lastRectangle = downRectangle;
        }        private void panelMain_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            ControlPaint.DrawReversibleFrame(lastRectangle, Color.White, FrameStyle.Thick);
            Rectangle rectangle = downRectangle;
            rectangle.Offset(e.X - downPoint.X, e.Y - downPoint.Y);
            ControlPaint.DrawReversibleFrame(rectangle, Color.White, FrameStyle.Thick);
            lastRectangle = rectangle;
        }
        
        private void panelMain_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            ControlPaint.DrawReversibleFrame(lastRectangle, Color.White, FrameStyle.Thick);
            control.Location = new Point(((Control)sender).Location.X + e.X - downPoint.X, ((Control)sender).Location.Y + e.Y - downPoint.Y);
            IsDepartControl(sender);
        }

解决方案 »

  1.   

    你说了等于没说,如果是用graphics画,双缓冲是可以,但是这个是用ControlPaint
      

  2.   

    你看看ppt里面那个拖动工具箱的时候是不闪的啊
      

  3.   

    汗~~ 沒人回答,最近csdn不行啊,我有很多問題都沒人回答了
      

  4.   

    既然你用的是ControlPaint方法,为什么不把ControlPaint类写全了?
    你的form需要做的事情就是初始化form,并传入form即可。Init(Control control){}
    把那些画图的工作都交给ControlPaint这个类就行了。
    另外,画图时尽量在Control_Paint(objece,e)里画。别用在mousemove里也画,mousedown里也画。
      

  5.   

    controlpaint与双缓冲没有什么关系.慢可能是由于你用到的offset导致的.