Datagridview隔行变色 ------在线等 Datagridview的那个事件可以捕获到每行的绑定事件,就像web下girdview的datarowbingding事件一样。我希望实现隔行变色的效果。web的做过,winform这个控件不知道怎么实现,谢谢大家了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void DgBase_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { for (int i = 0; i < DgBase.Rows.Count; i++) { if (i % 2 == 0) { DgBase.Rows[i].DefaultCellStyle.BackColor = Color.Gainsboro; ; } else { DgBase.Rows[i].DefaultCellStyle.BackColor = Color.PowderBlue; } } } 用AlerternatingRowDefaultCellStyle属性 在dataGridView1的CellFormatting属性中添加。 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex %2== 0 ) { e.CellStyle.BackColor = Color.AliceBlue; } } CSS/*DataGrid奇数行*/.EG_ItemCSS{ background-color: #e5ecf1;}/*DataGrid偶数行*/.EG_AlternatingItemCSS{ background-color: #d5e0e9;} 在类中定义的textBox1.text如何输出到主窗体? 关于表的设计与GRIDVIEW查询的问题 转换? C#中的treeview问题 VS2005C#语言如何制作精美图形报表(象股票那样) 求 利用serialport 实现短信发送接受的Example 帮忙解释下,看不懂。 数据库问题!多谢! 如何在C#程序中调用一个C++写DLL(非COM) 请问如何把HEX转换为字符串? 加载自定义控件闪烁问题 SQL BulkCopy错误4815: 从bcp 客户端收到一个对colid %d 无效的列长度
{
for (int i = 0; i < DgBase.Rows.Count; i++)
{
if (i % 2 == 0)
{
DgBase.Rows[i].DefaultCellStyle.BackColor = Color.Gainsboro; ;
}
else
{
DgBase.Rows[i].DefaultCellStyle.BackColor = Color.PowderBlue;
} }
}
{
if (e.RowIndex %2== 0 )
{
e.CellStyle.BackColor = Color.AliceBlue;
}
}
/*DataGrid奇数行*/
.EG_ItemCSS
{
background-color: #e5ecf1;
}
/*DataGrid偶数行*/
.EG_AlternatingItemCSS
{
background-color: #d5e0e9;
}