C# 隐藏DataGridView网格线
我看到了这个问题,并将C# 隐藏DataGridView网格线,c#,winforms,datagridview,.net-2.0,C#,Winforms,Datagridview,.net 2.0,我看到了这个问题,并将CellBorderStyle设置为None,但出于某种原因,我仍然在DataGridView上获得网格线: 这是我用来初始化控件的代码: public FtpTransferGridView() { this.AutoGenerateColumns = false; this.DoubleBuffered = true; this.ReadOnly = true; this.AllowUserToAddRows = false;
CellBorderStyle
设置为None
,但出于某种原因,我仍然在DataGridView
上获得网格线:
这是我用来初始化控件的代码:
public FtpTransferGridView()
{
this.AutoGenerateColumns = false;
this.DoubleBuffered = true;
this.ReadOnly = true;
this.AllowUserToAddRows = false;
this.AllowUserToDeleteRows = false;
this.AllowUserToResizeRows = false;
this.ShowEditingIcon = false;
this.RowHeadersVisible = false;
this.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(240, 240, 225);
this.RowTemplate.Height = 20;
this.CellBorderStyle = DataGridViewCellBorderStyle.None;
this.BackgroundColor = System.Drawing.SystemColors.Window;
InitializeColumns();
}
我在这里遗漏了什么?问题与自定义绘制的进度列单元格有关 在它的单元格绘制方法中,我的代码类似于:
base.Paint(g, ...);
g.SmoothingMode = SmoothingMode.HighQuality;
if (value <= 0) return;
//paint the progress bar
g.SmoothingMode = SmoothingMode.None;
问题与自定义绘制的进度列单元格有关 在它的单元格绘制方法中,我的代码类似于:
base.Paint(g, ...);
g.SmoothingMode = SmoothingMode.HighQuality;
if (value <= 0) return;
//paint the progress bar
g.SmoothingMode = SmoothingMode.None;
您是否尝试了dataGridView1.AdvancedCellBorderStyle.All=DataGridViewAdvancedCellBorderStyle.None代码>@V4Vendetta是的,我有,那没有帮助。查看我的答案以了解问题所在。您是否尝试了dataGridView1.AdvancedCellBorderStyle.All=DataGridViewAdvancedCellBorderStyle.None代码>@V4Vendetta是的,我有,那没有帮助。看我的答案,问题出在哪里。我想你也应该把相关的绘画逻辑作为问题的一部分发布,因为它与问题无关。问题在于,当方法完成时,
SmoothingMode
保持在High Quality
状态,并被系统用于绘制其他单元格及其边框,这显然导致了网格线的绘制。我想你也应该将相关的绘制逻辑作为问题的一部分发布,因为它不是推断出来的。@V4Vendetta绘制逻辑与问题无关。问题是当该方法完成时,SmoothingMode
保持在High Quality
状态,并被系统用于绘制其他单元格及其边界,这显然导致绘制网格线。