winform,把鼠标移到gridview的表头单元格上怎么变背景颜色
解决方案 »
- 求正则表达式
- C#中string.Format的格式参数问题
- 新手请教变量调用问题
- 加载XML文件的问题
- [c#]datagridview遍历问题
- c# 中字符串替换的问题
- 有什么方法可以避免循环交叉读取数据库啊。c#里有没有类似于java的list和vo啊
- 在vs2005中智能设备下编程,picturebox框显示图片的代码总是出错
- 用vs。net写程序,每次改一个小的地方,都要编译一次,而且编译很慢,有没有快点的办法,比如就编译改的这一页
- 关于OleDBDataOption中的UpdateDataSet引发异常UpdateCommand 影响了预期 1 条记录中的 0 条
- C#线程,能不能每个线程都能控制控件输出呀
- c#图片保存问题
好像是这样的
你看下,是不是可以设置到,
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
Color mLinearColor1 = Color.FromArgb(255, 255, 0); //列头颜色
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.OnPaint(e);
}