请问datagridview的网格线的问题 我想修改列的网格线的颜色,就是竖着的线的颜色,而且想设置每列之间的线的颜色不一致,我式了一下gridcolor貌似不行..麻烦哪位大虾指导下我,谢谢~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // Change the Border and Gridline Styles in the Windows Forms DataGridView ControlSamples: this.dataGridView1.GridColor = Color.BlueViolet; this.dataGridView1.BorderStyle = BorderStyle.Fixed3D; this.dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None; this.dataGridView1.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; this.dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; 只能自己画了,datagridview绘制的时候,是按单元格来绘制的矩形,按你的要求就是绘制矩形的左右边框颜色不同了给你一段代码是绘制行头和列头的 protected override void OnCellPainting(System.Windows.Forms.DataGridViewCellPaintingEventArgs e) { Color mLinearColor1 = Color.FromArgb(248, 250, 251); Color mLinearColor2 = Color.FromArgb(196, 207, 224); Color mGridColor = Color.FromArgb(120, 147, 191); //网格线的颜色 Color mHasFocusedColor = Color.DarkCyan; //控件的焦点框颜色 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(); } } /*不显示焦点颜色*/ this.DefaultCellStyle.SelectionBackColor = Color.Transparent ; this.DefaultCellStyle.SelectionForeColor = Color.Black ; base.OnCellPainting(e); } oracle nvl条件查询问题 C#窗体应用程序如何播放声音文件? winform 有没有进程结束类似的事件啊 大家好 C#中连接数据库问题,请教! asp.net使用GridView的一些疑问 非常感谢!cansum396 想用C#编程,我是菜鸟,电脑上要装什么软件,SDK之类的?流程是什么? textbox中的内容为什么不显示?? vs.net的中文正式版出来了没?如果没出,是否有哪位知道微软什么时候出中文版? 訪問頁面報錯..server application unavailable 当单选按钮选中时如何判断当前用户是否已经登陆
this.dataGridView1.GridColor = Color.BlueViolet;
this.dataGridView1.BorderStyle = BorderStyle.Fixed3D;
this.dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;
this.dataGridView1.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
this.dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
给你一段代码是绘制行头和列头的 protected override void OnCellPainting(System.Windows.Forms.DataGridViewCellPaintingEventArgs e)
{
Color mLinearColor1 = Color.FromArgb(248, 250, 251);
Color mLinearColor2 = Color.FromArgb(196, 207, 224);
Color mGridColor = Color.FromArgb(120, 147, 191); //网格线的颜色
Color mHasFocusedColor = Color.DarkCyan; //控件的焦点框颜色
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();
} } /*不显示焦点颜色*/
this.DefaultCellStyle.SelectionBackColor = Color.Transparent ;
this.DefaultCellStyle.SelectionForeColor = Color.Black ;
base.OnCellPainting(e);
}