Reputation: 21917
I've seen this question, and have set CellBorderStyle
to None
, but for some reason I am still getting gridlines on my DataGridView
:
This is the code I am using to initialize my control:
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();
}
What am I missing here?
Upvotes: 1
Views: 2515
Reputation: 21917
The problem was related to the custom painted progress column cells.
In it's cell paint method I had code similar to:
base.Paint(g, ...);
g.SmoothingMode = SmoothingMode.HighQuality;
if (value <= 0) return;
//paint the progress bar
g.SmoothingMode = SmoothingMode.None;
The error would happen when the method would exit without painting the progress bar, leaving the graphics smoothing mode in an incorrect state.
Settings the SmoothingMode
of the Graphics
only after the value <= 0
check solves the problem:
base.Paint(g, ...);
if (value <= 0) return;
g.SmoothingMode = SmoothingMode.HighQuality;
//paint the progress bar
g.SmoothingMode = SmoothingMode.None;
Upvotes: 1