Search code examples
c#winformsanimated-gif

How do you show animated GIFs on a Windows Form (c#)


I have a form showing progress messages as a fairly long process runs. It's a call to a web service so I can't really show a percentage complete figure on a progress bar meaningfully. (I don't particularly like the Marquee property of the progress bar)

I would like to show an animated GIF to give the process the feel of some activity (e.g. files flying from one computer to another like Windows copy process).

How do you do this?


Solution

  • It's not too hard.

    1. Drop a picturebox onto your form.
    2. Add the .gif file as the image in the picturebox
    3. Show the picturebox when you are loading.

    Things to take into consideration:

    • Disabling the picturebox will prevent the gif from being animated.

    Another way of doing it:

    Another way that I have found that works quite well is the async dialog control that I found on the code project