我正在尝试以滑动效果将控件移动到另一个控件的位置。下面的代码有效,但并不像预期的那样顺利。我知道每移动一个像素都必须重新绘制,这与这个问题有关。有什么办法可以让它顺利吗?
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);
}
}