[讨论]谁能告诉我表格控件设置行背景?
有哪位朋友能告诉我哪个表格控件的行背景色可以单独设置?如一个10行10列的表格:
设置第二行的背景色为红色;
设置第8行的背景色为绿色.
我有的是VS.NET 2003 ,有这个控件吗?
看来没有人这么用过呀,郁闷!
在2005里可以用
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == 2 )
e.CellStyle.BackColor = Color.Red;
if (e.RowIndex == 8 )
e.CellStyle.BackColor = Color.Green;
}
或者
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.RowIndex == 2 )
e.CellStyle.BackColor = Color.Red;
if (e.RowIndex == 8 )
e.CellStyle.BackColor = Color.Green;
}
2003里没试过
[此贴子已经被作者于2007-1-5 11:25:50编辑过]