views:

650

answers:

2

I'd like to show an animated GIF as the tab image on a TabPage.

If I add my image to an ImageList and use the TabPage.ImageIndex property, it only shows the first frame (and doesn't animate):

ImageList imageList = new ImageList();
imageList.Images.Add(Properties.Resources.my_animated_gif);

tabControl.ImageList = imageList;
tabPage.ImageIndex = 0;

A few forums on the net also suggest ImageList doesn't support animated GIFs.

Is there an easy way to display an animated GIF as an image on a TabPage? Do I have to owner-draw and animate the image?

+1  A: 

The ImageList doesn't support animated gifs. Because of this and because TabPage has only an ImageIndex property to display image in the tab, you cannot add animated gifs to the TabPage.

There is a commercial 3rd party control IntegralUI TabControl which has an option to add animated gifs to the TabPage. In this control every TabPage apart from using ImageIndex also has Image and SelectedImage properties. These properties can be used to add animated gifs.

To start animation is simple:

  1. Set the AllowImageAnimation property for a specific TabPage to true
  2. Call the StartAnimation method for this page
  3. To stop an animation just call the StopAnimation method

You can download this control from here.

Lokey
A: 

I recommend (for a free solution) using a background worker that updates the icon programatically in a loop (and checks weather to stop or go on). It's a bit complex but I think you get the idea right? =P

Camilo Martin