请问winform的程序中datagridview 的表头能设置背景图片吗?

blackrain06 2011-07-15 11:20:18
如题,谢谢各位!
...全文
80 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
isjoe 2011-07-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 loosin2319 的回复:]
回帖 是不是 会加积分啊
[/Quote]

加可用分,
loosin2319 2011-07-15
  • 打赏
  • 举报
回复
回帖 是不是 会加积分啊
isjoe 2011-07-15
  • 打赏
  • 举报
回复
// 绘制背景色,不过这里的绘制无法连贯,你再研究一下吧。
写错了,是绘制背景图
isjoe 2011-07-15
  • 打赏
  • 举报
回复

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;
}

}

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧