如题,谢谢各位!

解决方案 »

  1.   


    private 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.Graphics.DrawImage(global::WindowsApplication6.Properties.Resources.主页0, e.CellBounds.X, e.CellBounds.Y);
                    
                    e.PaintContent(e.CellBounds);
                    e.Handled = true;
                }        }