I Need to move a picture in my Windows Forms application.
This works but is terribly slow. Are there any ways to move a picture faster? I want to do this because I want to reach a "Flyin' effect".
// First try
for (int i = 0; i < 500; i++)
{
//Tempbox is a picturebox
this.Tempbox.Location = new Point(this.Tempbox.Left++, 0);
Application.DoEvents();
System.Threading.Thread.Sleep(50);
}
// Second try
using (Graphics g = Graphics.FromImage(BufferBm))
{
for (int i = 0; i < 500; i++)
{
g.DrawImage(tempContolImage, new System.Drawing.Point(i, 0));
this.Tempbox.Image = BufferBm;
Application.DoEvents();
System.Threading.Thread.Sleep(50);
}
}