怎么将winform中的datagridview控件的 某一列改为倒计时的功能
想要实现的效果:
在datagridview 的一列实现 动态倒计时效果
计算倒计时用的时间是取本地时间还是服务器时间?
public static DateTime startTime ;
private void update_countdown_click(object sender, EventArgs e)
{
Timer t = new Timer();
t.Interval = 500;
t.Tick += new EventHandler(t_Tick);
t.Start();
}
void t_Tick(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.IsNewRow) continue;
var start_time_string = row.Cells[2].Value;
startTime = Convert.ToDateTime(start_time_string);
TimeSpan ts = startTime.Subtract(DateTime.Now);
row.Cells[1].Value = ts.ToString("dd'天 'hh':'mm':'ss''");
}
}
结果: