|
|
Title | Use an ImageList control to animate a series of images in VB .NET |
Description | This example shows how to use an ImageList control to animate a series of images in VB .NET. |
Keywords | ImageList, animate, VB.NET |
Categories | Graphics, Controls, VB.NET |
|
|
The images are stored in an ImageList control. When the program starts, it saves the number of images.
When the Timer fires, the program uses CreateGraphics to make a Graphics object for the form. It uses the object's DrawImage method to display the next image on the form.
|
|
Private m_Index As Integer
Private m_NumImages As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
m_NumImages = ImageList1.Images.Count
m_Index = -1
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
m_Index = (m_Index + 1) Mod m_NumImages
Dim gr As Graphics = Me.CreateGraphics()
gr.DrawImage(ImageList1.Images(m_Index), 10, 10)
End Sub
|
|
|
|
|
|