winform datagridview 如何设置datagridview隔行变色

房东的猫 提交于 2019-12-01 06:18:31
原文:winform datagridview 如何设置datagridview隔行变色

如何设置隔行变色。

如图:

设置:只要设置如下属性,就行了。

AlternatingRowsDefaultCellStyle 属性
获取或设置应用于 DataGridView 的奇数行的默认单元格样式。
RowsDefaultCellStyle 属性
获取或设置应用于 DataGridView 的行单元格的默认样式。
只需要增加以下代码即可实现隔行变色
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Bisque;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!