如果你想在你的窗體的相同位置,以顯示您的圖片(即你的圖片框被放在非常相同的點),你可以得到使用List(Of T)
的,並且只使用一個圖片框代替。每個圖像都可以通過索引訪問,您應該將其保存在變量中以跟蹤您當前顯示的圖像。
'Class level (outside any Sub or Function, but inside Public Class).
Dim Images As New List(Of Image)
Dim ImageIndex As Integer = 0
添加圖像:
Images.Add(Image.FromFile("your file path here"))
'or:
Images.Add(your image object)
卸下圖像:
Images.RemoveAt(zero-based index)
下一張圖片:
ImageIndex += 1
If ImageIndex >= Images.Count Then ImageIndex = 0 'Going back to the beginning if we're at the last image.
YourPictureBox.Image = Images(ImageIndex)
一張圖片:
件
ImageIndex -= 1
If ImageIndex < 0 Then ImageIndex = Images.Count - 1 'Going to the last image if we're in the beginning.
YourPictureBox.Image = Images(ImageIndex)
事情要記住使用List(Of T)
時:
爲什麼這個問題被標記爲 – kunz398