我有以下代码:当我尝试更换图像时程序挂起?
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv.Columns[e.ColumnIndex].Name.Equals("edit"))
{
string status = dataGridView1.Rows[e.RowIndex].Cells["status"].Value.ToString();
if (status == "1")
{
dgv.Rows[e.RowIndex].Cells["edit"].Value = Properties.Resources.edit_disable;
}
}
}
当我试图在这里替换图片:
dgv.Rows[e.RowIndex].Cells["edit"].Value = Properties.Resources.edit_disable;
程序挂起和形象,呈现无限
有你尝试删除并重新添加此资源? –
是的,它是DataGridViewImageColumn – OPV
通过代码来查看是否发生无限循环。在'dataGridView1_CellFormatting'事件改变'dgv.Rows [e.RowIndex] .Cells [ “编辑”]',它再次闪光'dataGridView1_CellFormatting',这改变'dgv.Rows [e.RowIndex] .Cells [ “编辑”]' ,无限广告。 –