首先,先创建一个新的winform项目ImageTest,选择窗体,起名我ImageForm,在ImageForm拉一个picturebox控件,一个控制器trimer,一个相册imageList,在imagesList控件中Images添加你要切换的图片,并设置一下图片的大小。以下是实际代码实现
public partial class ImageForm : Form
{
public ImageForm()
{
InitializeComponent();
}
private int ImageIndex = 0;
/// <summary>
/// 加载
/// </summary>
/// <param name="imagelist">存放图片集合</param>
/// <param name="picturebox">显示图片的框</param>
private void ImageForm_Load(object sender, EventArgs e)
{
//初始化显示第一张图片
this.pictureBox.Image = this.imageList1.Images[0];
//设置定时器切换时间间隔
this.timerImage.Interval = 1000;