帮我看下如何让图片永久循环C#

来源:百度知道 编辑:UC知道 时间:2024/06/10 09:45:54
private int index = 0;
private string[] imagelist;
private void Form1_Load(object sender, EventArgs e)
{
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=11.11.11.11;uid=root;" + "pwd=;database=image;";

BindingSource binds = new BindingSource();
conn = new MySql.Data.MySqlClient.MySqlConnection();
conn.ConnectionString = myConnectionString;
conn.Open();

MySqlDataAdapter da = new MySqlDataAdapter("select iname from spad", conn);
DataSet ds = new DataSet();
da.Fill(ds, "iname");

DataTable dt = ds.Tables[0];
if ((dt == null) || (dt.Rows.Count == 0))
{
MessageBox.Show(&q

private void timer2_Tick(object sender, EventArgs e)
{
if (imagelist == null)
return;
if (imagelist.Length < index + 1)
{
timer1.Stop();
return;
}
Image myimage = Image.FromFile(imagelist[index]);
pictureBox1.Image = myimage;
index++;

}
这一段里边,
if (imagelist.Length < index + 1)
{
//timer1.Stop(); 去掉该行
index=0; //加入
return;
}

这个方法 第二个if改成这样

private void timer2_Tick(object sender, EventArgs e)
{
if (imagelist == null)
return;
if (imagelist.Length < index + 1)
{
index = 0
}
Image myimage = Image.FromFile