Hello, I discovered a bug. It happens when cells are stained.
It is then no longer possible to edit a cell correctly. The result is two superimposed representations.
I’ve attached a screenshot showing the error-cell in edit. A sample project that generated this error has been attached.
The important part of the program:
private void dataGridView1_Appear(object sender, EventArgs e)
{
int amount = 10;
DataGridView dg = (DataGridView) sender;
dg.Rows.Add(amount);
for (int row = 0; row < amount; row++)
{
for (int col = 0; col < 6; col++)
{
dg.Rows[row].Cells[col].Value = row.ToString();
}
}
dg.Columns[2].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(88, 52, 255, 198);
}
I hope it’s not really a bug, but a misprogramming on my part.
Could anyone help me here?
It is not a bug. The sample puts a transparent color in the editing control. A transparent color shows what is behind-thus, why you can see the previous value as the cell is being edited.
Change this:
dg.Columns[2].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(88, 52, 255, 198);
to this: (removes the transparency)
dg.Columns[2].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(52, 255, 198);
The first argument in System.Drawing.Color.FromArgb(88, 52, 255, 198)
-in this case 88- is the alpha value, which controls the transparency.
If you send only 3 arguments, there is no alpha value.
HTH,
Julie
The code snippet you provided should work. See edited version of your sample- works fine.
The issue must be caused by a different part of the code.
Hello Julie,
good tip.
The alpha value is important to me. I want to preserve the color gradation of the even and odd color gradations of the lines. see screenshot. It looks smother.
I’ve been thinking about this here:
private void dataGridViewBrush_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
DataGridView dgv = (DataGridView)sender;
CellColorBeforEdit = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].InheritedStyle.BackColor;
Color newcolor = Color.FromArgb(CellColorBeforEdit.R, CellColorBeforEdit.G, CellColorBeforEdit.B);
dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = newcolor;
}
private void dataGridViewBrush_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = (DataGridView)sender;
dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = CellColorBeforEdit;
}
I remove the alpa channel while editing and add it back after editing.
OK. >> functioned . No ghosting during editing.
Next problem. After editing, no cell entry is visible. Do I need to adjust the visibility of the cell somehow? (sreenshot cell 17Z, 16H or 20Z was editing.)
Walter
Thanks for letting us know, we are investigating the issue.
-Julie
Please login first to submit.