Hi,
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to stored a list of
animated gif into an imagelist and use the picturebox to show the picture
in the imagelist.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
I think ImageList did not support the animated gif so far. To wordaround
the problem, I think in the IDE we can add the GIFs to the project and
changed their "Build Action" property to "Embedded Resource". Then we can
read them out into an arraylist and use them similar as the imagelist.
Here goes the code.
'I add a test.gif into the project.
Dim pics As ArrayList
Dim imgStream As Stream = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
pics = New ArrayList
Dim bmp As Bitmap = Nothing
' get a reference to the current assembly
Dim a As [Assembly] = [Assembly].GetExecutingAssembly()
' get a list of resource names from the manifest
Dim resNames As String() = a.GetManifestResourceNames()
Dim s As String
For Each s In resNames
If s.EndsWith(".gif") Then
' attach to stream to the resource in the manifest
imgStream = a.GetManifestResourceStream(s)
If Not imgStream Is Nothing Then
' create a new bitmap from this stream and
' add it to the arraylist
bmp = Image.FromStream(imgStream) '
If Not bmp Is Nothing Then
pics.Add(bmp)
End If
bmp = Nothing
End If
End If
Next s
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.PictureBox1.Image = pics(0)
End Sub
Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
imgStream.Close()
imgStream = Nothing
End Sub
Please apply my suggestion above and let me know if it helps resolve your
problem.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.