Next & Previous Buttons

  • Thread starter Thread starter karim
  • Start date Start date
K

karim

Hello All,
if I have this code:
PictureBox1.ImageLocation = "c:\file.jpg"

would I be able to add a next & prevous bottons to go to the next picture in
this folder or the previous one? and if I was able to do so, would be there a
simple code for next and previous?

thank you all for your help...
 
At initialization, you could set up the list of files, possibly by calling
GetFiles() on an instance of DirectoryInfo. All that the Previous and Next
buttons should do is to increase or decrease an index into the list of files,
and set the image location property to the fullname property of the fileinfo
object in your array.
 
Hello All,
if I have this code:
                         PictureBox1.ImageLocation = "c:\file.jpg"

would I be able to add a next & prevous bottons to go to the next picturein
this folder or the previous one? and if I was able to do so, would be there a
simple code for next and previous?

thank you all for your help...

As you can add all paths of images to an array using GetFiles method
under DirectoryInfo, you can also consider using ImageList control
from your toolbox.

You can Google for usage of ImageList control.

Hope this helps,

Onur Güzel
 
karim said:
if I have this code:
PictureBox1.ImageLocation = "c:\file.jpg"

would I be able to add a next & prevous bottons to go to the next picture
in
this folder or the previous one? and if I was able to do so, would be
there a
simple code for next and previous?

Untested:

\\\
Private m_Files() As String
Private m_CurrentFile As Integer

Private Sub Form1_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Load
m_Files = Directory.GetFiles("C:\Users\Public\Pictures\Sample Pictures")
ShowCurrentFile()
End Sub

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
If m_CurrentFile < m_Files.Length - 1 Then
m_CurrentFile += 1
End If
ShowCurrentFile()
End Sub

Private Sub Button2_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button2.Click
If m_CurrentFile > 0 Then
m_CurrentFile -= 1
End If
ShowCurrentFile()
End Sub

Private Sub ShowCurrentFile()
Me.PictureBox1.ImageLocation = m_Files(m_CurrentFile)
End Sub
///
 
Back
Top