关于imagelist使用的一点问题?
本帖最后由 happywork8 于 2013-02-06 21:10:21 编辑 想了以下这个问题好一会,都没想明白?
目的:使用imagelist动态变换Label2.Image
使用第一种方法,ImageList1.Images.Add动态加入图片,如下,可以实现正常的动态变换Label2.Image
Dim x As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label2.AutoSize = True
ImageList1.ImageSize = New Size(256, 256)
ImageList1.Images.Add(System.Drawing.Image.FromFile("C:\Users\user\Pictures\1152.gif"))
ImageList1.Images.Add(System.Drawing.Image.FromFile("C:\Users\user\Pictures\1166.gif"))
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If x > 1 Then x = 0
Label2.Image = ImageList1.Images(x)
x += 1
End Sub
Dim x As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label2.AutoSize = True
ImageList1.ImageSize = New Size(256, 256)
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If x > 1 Then x = 0
Label2.Image = ImageList1.Images(x)
x += 1
End Sub