R – Loading gif for a winform

gifloadingwinforms

Loading gif for a winform, when i click a button i need to show loading gif then after some action it should not be displayed.

I can find tutorial for web form, but am struggling to do the same for winform, pls. suggest some idea.

Thanks,
Karthick

Best Answer

The standard PictureBox control can display animated GIFs.

Make a PictureBox on your form, set its Image property to an animated GIF, and set its Visible property to false.

Then, when you want to perform your action, set the PictureBox's Visible property to true in code, perform the action, and set it to false again.

Note that if you perform your action on the UI thread, the form, including the animation, will freeze until it finishes. To solve this, look at the BackgroundWorker component.

Related Topic