C#单击按钮显示图片,带开始停止

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 WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
//取图片
pictureBox1.Image = imageList1.Images[0];
}

private void button2_Click(object sender, EventArgs e)
{
timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
int i;
Random r = new Random();
i = r.Next(0, imageList1.Images.Count);
pictureBox1.Image = imageList1.Images[i];

}

private void button3_Click(object sender, EventArgs e)
{
timer1.Stop();
}
}
}

你可能感兴趣的:(C#)