图片框,图像列表和计时器的使用

来源:互联网 发布:java安装失败找不到uri 编辑:程序博客网 时间:2024/04/29 23:12
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace 图片框_图像列表和计时器的使用{    public partial class Form1 : Form    {        private int index;        public Form1()        {            InitializeComponent();        }        private void pictureBox1_SizeChanged(object sender, EventArgs e)        {            this.pictureBox1.Left = (this.ClientSize.Width - this.pictureBox1.Width) / 2;        }        private void Form1_Load(object sender, EventArgs e)        {            index = 0;            this.pictureBox1.Image = this.imageList1.Images[index];            this.label1.Text = "图片" + (index + 1).ToString();        }        private void timer1_Tick(object sender, EventArgs e)        {            if (index == 6)                index = 0;            else index++;            this.pictureBox1.Image = this.imageList1.Images[index];            this.label1.Text = "图片" + (index + 1);        }    }}

原创粉丝点击