نمایش چندین عکس در PictureBox

برای نمایش چندین عکس در PictureBox یک برنامه به صورت زیر ایجاد کنید :
multiple-images-in-picturebox-c#

و سپس کدهای زیر را در رویداد کلیک دکمه ها بنویسید :

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.IO;

namespace PaginatePictureBox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private List<string> AllImages = new List<string>();
        private int ImageCounter = 0;

        //Load images in picturebox
        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FolderBrowserDialog1 = new FolderBrowserDialog();
            if (FolderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                AllImages.Clear();

                DirectoryInfo dirInfo = new DirectoryInfo(FolderBrowserDialog1.SelectedPath);
                if (dirInfo.GetFiles().Count() > 0)
                {

                    FileInfo[] allFiles = dirInfo.GetFiles();
                    for (int i = 0; i < allFiles.Count(); i++)
                    {
                        if (allFiles[i].Extension.ToLower() == ".jpg")
                        {
                            this.AllImages.Add(allFiles[i].FullName);
                        }
                    }
                }

                this.ImageCounter = 0;
                this.pictureBox1.Image = Image.FromFile(this.AllImages[this.ImageCounter]);
            }
        }

        // Next button codes       
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.ImageCounter < this.AllImages.Count - 1)
            {
                this.ImageCounter++;
                this.pictureBox1.Image = Image.FromFile(this.AllImages[this.ImageCounter]);
            } 
        }

        // Previews button codes
        private void button3_Click(object sender, EventArgs e)
        {
            if (this.AllImages.Count > 0 && this.ImageCounter > -1)
            {
                if (this.ImageCounter > 0)
                {
                    this.ImageCounter--;
                }
                this.pictureBox1.Image = Image.FromFile(this.AllImages[this.ImageCounter]);
            }
        }
    }
}

در کد بالا فقط عکس های با پسوند jpg در picturebox نمایش داده می شوند.