Sliding in Winforms form

Posted by rs on Stack Overflow See other posts from Stack Overflow or by rs
Published on 2010-03-23T19:07:55Z Indexed on 2010/03/23 19:13 UTC
Read the original article Hit count: 610

Filed under:
|
|

Hi, I'm making a form at the bottom of the screen and I want it to slide upwards so I wrote the following code:

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);
}

but the code just runs through and shows the end position without showing the form sliding in which is what I want. I've tried Refresh, DoEvents - any thoughts?

© Stack Overflow or respective owner

Related posts about c#

Related posts about loop