日期:2014-05-18 浏览次数:21137 次
public Form1()
{
InitializeComponent();
this.dataGridView1.CellPainting += new DataGridViewCellPaintingEventHandler(dataGridView1_CellPainting);
}
void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == -1)
{
bool mouseOver = e.CellBounds.Contains(dataGridView1.PointToClient(Cursor.Position));
LinearGradientBrush brush = new LinearGradientBrush(
e.CellBounds,
mouseOver ? Color.PeachPuff : Color.LightGray,
Color.DarkOrange,
LinearGradientMode.Vertical);
using(brush)
{
e.Graphics.FillRectangle( brush, e.CellBounds);
Rectangle border = e.CellBounds;
border.Width -= 1;
e.Graphics.DrawRectangle( Pens.Gray, border);
}
e.PaintContent(e.CellBounds);
e.Handled = true;
}
}
------解决方案--------------------
唯一的可能性,你有隐藏列