/// <summary> /// 设置datagridview隔行变色 /// </summary> /// <param name="e">datagridview控件</param> public void setDgvRowColor(ref object sender) { try { DataGridView dgv = (DataGridView)sender; for (int i = 0; i < dgv.Rows.Count; i++) { if (i % 2 == 0) { dgv.Rows[i].DefaultCellStyle.BackColor = Color.White; } else { dgv.Rows[i].DefaultCellStyle.BackColor = Color.LightSteelBlue; } } } catch (Exception ex) { throw ex; } }