我现在的代码如下:好像只装了第一张图片进去。
private void timer1_Tick(object sender, EventArgs e)
{
string sql_str = "select * from cj_main";
SqlConnection conn = new SqlConnection(conn_str);
SqlCommand command = new SqlCommand(sql_str, conn);
conn.Open();
SqlDataReader rs = command.ExecuteReader();
if (rs.Read())
{
cj_names = rs[1].ToString();
cj_pic_path = rs[3].ToString();
List<Image> lst = new List<Image>();
lst.Add(Image.FromFile(cj_pic_path));
label1.Text = cj_names;
if (i >= lst.Count)
{
i = 0;
}
else
{
this.pictureBox1.Image = lst[i];
this.pictureBox1.Image = lst[i];
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
i = i + 1;
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
string sql_str = "select * from cj_main";
SqlConnection conn = new SqlConnection(conn_str);
SqlCommand command = new SqlCommand(sql_str, conn);
conn.Open();
SqlDataReader rs = command.ExecuteReader();
if (rs.Read())
{
cj_names = rs[1].ToString();
cj_pic_path = rs[3].ToString();
List<Image> lst = new List<Image>();
lst.Add(Image.FromFile(cj_pic_path));
label1.Text = cj_names;
if (i >= lst.Count)
{
i = 0;
}
else
{
this.pictureBox1.Image = lst[i];
this.pictureBox1.Image = lst[i];
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
i = i + 1;
}
}
}
解决方案 »
- C#关于DataTable
- C# winform里,在主窗体里播放flash,主窗体里有个添加按钮,点击添加会弹出子窗体,在子窗体里浏览添加flash,同时确定,也就是添加的过程是在子窗体里完成,完成后子窗体关闭,当子窗体关闭时怎样让刚才添加的flash在主窗体里显示呢?
- 我在outlook里加了Ribbon,为什么运行的时候没有反应,在word2007里就直接看到效果了
- datagrid在web中的应用。
- button2如何显示调用button1的Click事件
- 高手请进 .net2005的问题
- 关于数据库用dataGrid显示的问题
- 关于无句柄窗体的一个疑问
- 超级难题,string 类型的"+,-,*,/,(,)"如何能转换成运算符啊?
- rdlc报表导出Excel行高和报表行高不一致,求解决办法
- 提问散分!
- socket一点问题
SqlConnection conn = new SqlConnection(conn_str);
SqlCommand command = new SqlCommand(sql_str, conn);
conn.Open();
SqlDataReader rs = command.ExecuteReader();你这代码放在tick事件中,那么,不是每次查询结果都一样么?
public Form1()
{
InitializeComponent();
string sql_str = "select * from cj_main";
SqlConnection conn = new SqlConnection(conn_str);
SqlCommand command = new SqlCommand(sql_str, conn);
conn.Open();
SqlDataReader rs = command.ExecuteReader();
}
使用List<T>等
Load中获取数据到list<T>,在调用List<T>