2013-01-23 110 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); 
    } 
} 

回答