Put the image on the form and specify the file with the Gif extension. Or:
Programmatically animate gif Loading images into a PictureBox with code, here's the Gif class:
Vb.net
Public Class GifImage Private gifImage As Image Private dimension As FrameDimension Private frameCount As Integer Private currentFrame As Integer = -1 Private reverse As Boolean Private [step] As Integer = 1 Public Sub New(path As String) gifImage = Image.FromFile(path) 'initialize dimension = New FrameDimension(gifImage.FrameDimensionsList(0)) 'gets the GUID 'total frames in the animation frameCount = gifImage.GetFrameCount(dimension) End Sub Public Property ReverseAtEnd() As Boolean 'whether the gif should play backwards when it reaches the end Get Return reverse End Get Set reverse = value End Set End Property Public Function GetNextFrame() As Image currentFrame += [step] 'if the animation reaches a boundary... If currentFrame >= frameCount OrElse currentFrame < 1 Then If reverse Then [step] *= -1 '...reverse the count 'apply it currentFrame += [step] Else currentFrame = 0 '...or start over End If End If Return GetFrame(currentFrame) End Function Public Function GetFrame(index As Integer) As Image gifImage.SelectActiveFrame(dimension, index) 'find the frame Return DirectCast(gifImage.Clone(), Image) 'return a copy of it End Function End Class
FROM#
public class GifImage { private Image gifImage; private FrameDimension dimension; private int frameCount; private int currentFrame = -1; private bool reverse; private int step = 1; public GifImage(string path) { gifImage = Image.FromFile(path);
Using C #:
Open a Winform project with drag and drop in the PictureBox, Timer, and Button with the GifImage.cs class shown above.
public partial class Form1 : Form { private GifImage gifImage = null; private string filePath = @"C:\Users\Jeremy\Desktop\ExampleAnimation.gif"; public Form1() { InitializeComponent();

Jeremy thompson
source share