隐藏DataGridView网格线

时间:2013-01-28 06:49:21

标签: c# winforms datagridview .net-2.0

我看到了this个问题,并将CellBorderStyle设置为None,但由于某种原因,我仍然在我的DataGridView上获得网格线:

enter image description here

这是我用来初始化控件的代码:

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

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

问题与自定义绘制的进度列单元格有关。

在它的单元格绘制方法中,我的代码类似于:

base.Paint(g, ...);
g.SmoothingMode = SmoothingMode.HighQuality;
if (value <= 0) return;

//paint the progress bar

g.SmoothingMode = SmoothingMode.None;

当方法退出而不绘制进度条时,会发生错误,使图形平滑模式处于错误状态。

仅在SmoothingMode检查解决问题后设置Graphics的{​​{1}}:

value <= 0