我在dataGridView1_Paint修改了显示字体的颜色,但运行多线程的时候winform会卡,出现假死,这是什么原因呢?
private void dataGridView1_Paint(object sender, PaintEventArgs e)
{
for (int i = 0; i<=dataGridView1.Rows.Count - 1; i++)
{
DataGridViewRow CurrRow = dataGridView1.Rows[i];
try
{
if (CurrRow.Cells[3].Value.ToString() == "未处理")
{
CurrRow.DefaultCellStyle.ForeColor = Color.Black;
}
if (CurrRow.Cells[3].Value.ToString()=="已处理")
{
CurrRow.DefaultCellStyle.ForeColor=Color.DodgerBlue;
}
if (CurrRow.Cells[3].Value.ToString() == "已回复")
{
CurrRow.DefaultCellStyle.ForeColor = Color.DodgerBlue;
}
}
catch (Exception ex)//异常处理
{
Console.WriteLine(ex.Message);
}
}
private void dataGridView1_Paint(object sender, PaintEventArgs e)
{
for (int i = 0; i<=dataGridView1.Rows.Count - 1; i++)
{
DataGridViewRow CurrRow = dataGridView1.Rows[i];
try
{
if (CurrRow.Cells[3].Value.ToString() == "未处理")
{
CurrRow.DefaultCellStyle.ForeColor = Color.Black;
}
if (CurrRow.Cells[3].Value.ToString()=="已处理")
{
CurrRow.DefaultCellStyle.ForeColor=Color.DodgerBlue;
}
if (CurrRow.Cells[3].Value.ToString() == "已回复")
{
CurrRow.DefaultCellStyle.ForeColor = Color.DodgerBlue;
}
}
catch (Exception ex)//异常处理
{
Console.WriteLine(ex.Message);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货