datagirdview每几秒刷新一次不同的数据显示
int j = 1;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
GetData(j);
}
private void Frm生产任务看板_Load(object sender, EventArgs e)
{
GetData(1);
}
private void GetData(int k)
{
string sql = string.Empty;
if (k == 1)
{
sql = @"select*from table1
";
label1.Text = "任务清单-已开始";
j = 2;
}
else if (k == 2)
{
sql = @"select * from table2";
label1.Text = "任务清单-计划中";
j = 3;
}
else if (k == 3)
{
sql = @"select * from table3";
label1.Text = "汇总信息-已开工";
j = 4;
}
else
{
sql = @"select * from table3
";
label1.Text = "汇总信息-计划中";
j = 1;
}
DataTable dt = DB.GetDataTable(sql);
dataGridView1.DataSource = dt.DefaultView;
dataGridView1.Update();
timer1.Enabled = true;
//用两个变量和一个时间控件来定义一个循环的逻辑