C# Tutorial: Create a image slide show v1

Full code for image slide show v1

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace buttonSlideShow
{
    public partial class Form1 : Form
    {
        int num = 0;

        public Form1()
        {
            InitializeComponent();
            pictureBox1.Image = Image.FromFile("img/1.jpg");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            num++;
            if (num == 6)
            {
                num = 1;
            }
            pictureBox1.Image = Image.FromFile("img/" + num + ".jpg");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            num--;
            if (num <1)
            {
                num = 1;
            }
            pictureBox1.Image = Image.FromFile("img/" + num + ".jpg");
        }

    }
}





Comments are closed.