我正在屏幕底部制作一个表单,我希望它向上滑动,所以我编写了以下代码:
int destinationX = (Screen.PrimaryScreen.WorkingArea.Width / 2) - (this.Width / 2);
int destinationY = Screen.PrimaryScreen.WorkingArea.Height - this.Height;
this.Location = new Point(destinationX, destinationY + this.Height);
while (this.Location != new Point(destinationX, destinationY))
{
this.Location = new Point(destinationX, this.Location.Y - 1);
System.Threading.Thread.Sleep(100);
}
Run Code Online (Sandbox Code Playgroud)
但代码只是贯穿并显示结束位置而没有显示形式滑动,这就是我想要的.我尝试过Refresh,DoEvents - 任何想法?
尝试使用Timer事件而不是循环.