日期:2014-05-19  浏览次数:20879 次

datagridview怎么设置每行的颜色呀
datagridview怎么设置每行的颜色呀

------解决方案--------------------
this.dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
------解决方案--------------------
摘录:《程序员秘书》--组件和控件--DataGridView数据显示控件
轻松开发软件,详见:http://www.psec.net.cn

10、在Form1.cs的视图设计器中,选中button5,在属性框中选中事件,双击Click,在Form1.cs的代码设计器中,添加修改如下代码
private void button5_Click(object sender, EventArgs e)
{
dataGridView1.Rows[2].DefaultCellStyle.ForeColor = Color.Yellow;
dataGridView1.Rows[2].DefaultCellStyle.BackColor = Color.Green;
}

------解决方案--------------------
Dim dr As DataGridViewRow
dr.DefaultCellStyle.BackColor = color.red