日期:2014-05-18 浏览次数:21051 次
//高亮显示 private void DataGrid1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { if (e.RowIndex > DataGrid1.Rows.Count - 1) return; DataGridViewRow dgr = DataGrid1.Rows[e.RowIndex]; try { for (int i = 0; i < DataGrid1.Rows.Count; i++) { //dgr.Cells[12]是状态标志 if (dgr.Cells[12].Value.ToString() == "1" ) { //dgr.DefaultCellStyle.BackColor = Color.Red; dgr.DefaultCellStyle.ForeColor = Color.Blue; } else if (dgr.Cells[12].Value.ToString() == "2" ) { //冲销标志为0,但是被冲销号不是0,则说明是被冲的记录,令其为绿色 dgr.DefaultCellStyle.ForeColor = Color.Red; } if (dgr.Cells[14].Value.ToString() == "√") { dgr.DefaultCellStyle.BackColor = Color.LightBlue; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }