Lo que necesito hacer es crear un picturebox en el cual debo cargar varias imágenes y con botones de "Anterior" y "Siguiente" avanzar o retroceder en las imágenes, según sea el caso. Espero me puedan ayudar con eso.
Public imagestr As String() = {"imgs/img01.jpg", "imgs/img02.png", "imgs/img03.jpg", "c:/undir/imgs/img04.png"} Private imgs As New List(Of Bitmap) Private priv_index As Integer = 0
'utilizo una propiedad, de esta manera cuando cambie "index" la imágen 'se sitúa automáticamente en el picturebox
Public Property index As Integer Get Return Me.priv_index End Get Set(value As Integer) If value < 0 Then If imgs.Count > 0 Then value = imgs.Count - 1 End If ElseIf value >= imgs.Count Then value = 0 End If Me.priv_index = value
try Me.picturebox1.image = imgs(Me.priv_index) catch ex as exception ' no hay imágen ! end End Set End Property
' load imagelist lee un bitmap por cada texto en imagestr ' y lo memoriza en imgs
Public Sub load_imagelist() imgs.Clear() Dim tmp As Bitmap For Each s As String In Me.imagestr Try tmp = Bitmap.FromFile(s) Me.imgs.Add(tmp) Catch ex As Exception ' no se encuentra el archivo ' ¿notificar al usuario? End Try Next Me.index = 0 End Sub