能否给datagridview的列头设置背景图片? 找了半天没有找到,貌似只能设置背景颜色?是在不行设置为渐进色也行啊。谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //行头,列头背景颜色渐变 protected override void OnCellPainting(System.Windows.Forms.DataGridViewCellPaintingEventArgs e) { Color mLinearColor1 = Color.FromArgb(51, 122, 167); Color mLinearColor2 = Color.FromArgb(255, 255, 255); Color mGridColor = Color.FromArgb(120, 147, 191); //网格线的颜色 Rectangle Rect = new Rectangle(e.CellBounds.X - 1, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height - 1); LinearGradientBrush LinearGradientBrushs = new LinearGradientBrush(Rect, mLinearColor1, mLinearColor2, LinearGradientMode.Vertical); try { if (e.RowIndex == -1 || e.ColumnIndex == -1) { e.Graphics.FillRectangle(LinearGradientBrushs, Rect); e.Graphics.DrawRectangle(new Pen(mGridColor), Rect); e.PaintContent(e.CellBounds); e.Handled = true; } } catch { } finally { if (LinearGradientBrushs != null) { LinearGradientBrushs.Dispose(); } } base.OnCellPainting(e); } winform调用Webservice发生http 400 bad request错误 求C# 读取文件到DataSet的方法 在线等。。。。 关于C# 的hmacSHA1加密方法的使用 VB中Winsock控件在C#中实现的问题 C#winform中怎么让两个Listview的水平滚动条一起滚动 c# 中怎么创建新文件? 各位兄弟给点建议:一个DATAGRID控件能不能显示不同数据库中的多个表? 图表控件 问个接口设计问题 使用repositoryItemLookUpEdit遇到下拉值消失的问题 C#窗口间数据交换问题 C# 绘图/透视问题
protected override void OnCellPainting(System.Windows.Forms.DataGridViewCellPaintingEventArgs e)
{
Color mLinearColor1 = Color.FromArgb(51, 122, 167);
Color mLinearColor2 = Color.FromArgb(255, 255, 255);
Color mGridColor = Color.FromArgb(120, 147, 191); //网格线的颜色 Rectangle Rect = new Rectangle(e.CellBounds.X - 1, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height - 1);
LinearGradientBrush LinearGradientBrushs = new LinearGradientBrush(Rect, mLinearColor1, mLinearColor2, LinearGradientMode.Vertical);
try
{
if (e.RowIndex == -1 || e.ColumnIndex == -1)
{
e.Graphics.FillRectangle(LinearGradientBrushs, Rect);
e.Graphics.DrawRectangle(new Pen(mGridColor), Rect);
e.PaintContent(e.CellBounds);
e.Handled = true;
}
} catch
{ }
finally
{
if (LinearGradientBrushs != null)
{
LinearGradientBrushs.Dispose();
} } base.OnCellPainting(e);
}