datagridview中,将所有值为1的单元格更改背景,我用for循环遍历单元格,最后的结果是最后一个值为1的单元格可以更改。
设置断点调试的结果是:每次遍历到值为1的单元格,更改背景颜色,然后遍历都下一个的时候原来更改的就又变成默认颜色。请高手帮帮忙,怎样才能让所有值为1 的单元格更改背景颜色 ?
设置断点调试的结果是:每次遍历到值为1的单元格,更改背景颜色,然后遍历都下一个的时候原来更改的就又变成默认颜色。请高手帮帮忙,怎样才能让所有值为1 的单元格更改背景颜色 ?
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "1")
e.CellStyle.BackColor = Color.Red;
}
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#B2DFEE'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
使用于asp.net IE
大侠你好,我做的不是asp~
非常感谢您的回答!