UserControl中Load事件设置datagridview色彩无效
UserControl中Load事件设置datagridview颜色无效1.下面这个是UserControl1中的Load事件的代码:加载的用户
UserControl中Load事件设置datagridview颜色无效
1.下面这个是UserControl1中的Load事件的代码:
加载的用户控件没有背景色,只剩下20分了,请帮忙看看,谢谢!
[解决办法]你想设置隔行的背景色不用这么麻烦,在用户控件中选择dataGridView控件,设置一下属性就可以了。
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Red;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.RoyalBlue;
[解决办法]我不是要这种简单的,实际情况是要判断行中某列的数据,给不同的颜色,不止两种颜色
LZ你要引用后对方才能看到!
[解决办法]private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
var i = e.RowIndex;
if (i % 2 == 0)
{
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
}
else
{
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.RoyalBlue;
}
}
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/