2013-01-23 177 views
3

我试图将滑动效果中的控件移动到另一个控件的位置。下面的代码有效,但不像预期的那样平滑。我知道重绘必须发生每一个像素的移动,并且这一切都与这个问题有关。有什么我可以做的,以使其顺利?幻灯片效果不光滑

void changePage(Control currentPage, Control newPage) 
{ 
    int curPageStartX = currentPage.Location.X; 
    newPage.Location = new Point(currentPage.Size.Width + curPageStartX, currentPage.Location.Y); 
    while (newPage.Location.X > curPageStartX) 
    { 
     currentPage.Location = new Point(currentPage.Location.X - 1, currentPage.Location.Y); 
     newPage.Location = new Point(newPage.Location.X - 1, newPage.Location.Y); 
    } 
} 

回答