Next & Previous Buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?a2FyaW0=?=

    Next & Previous Buttons

    Hello All,
    if I have this code:
    PictureBox1.Ima geLocation = "c:\file.jp g"

    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...
  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    RE: Next & Previous Buttons

    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.

    "karim" wrote:
    Hello All,
    if I have this code:
    PictureBox1.Ima geLocation = "c:\file.jp g"
    >
    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...

    Comment

    • kimiraikkonen

      #3
      Re: Next & Previous Buttons

      On Oct 13, 11:36 am, karim <ka...@discussi ons.microsoft.c omwrote:
      Hello All,
      if I have this code:
                               PictureBox1.Ima geLocation = "c:\file.jp g"
      >
      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

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Next &amp; Previous Buttons

        "karim" <karim@discussi ons.microsoft.c omschrieb:
        if I have this code:
        PictureBox1.Ima geLocation = "c:\file.jp g"
        >
        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.GetFi les("C:\Users\P ublic\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_Curre ntFile)
        End Sub
        ///

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        Working...