设置datagridview隔行变色
作者:互联网
/// <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; } }
标签:Rows,datagridview,隔行,dgv,ex,BackColor,变色 来源: https://www.cnblogs.com/6B23/p/12205724.html