Going from the previous question i had asked that related to color text change after edit. Now it has been requested that i should not highlight the edited text but change the background color.
This is what i want now.
- Load existing file with the data to the
DataGridView
- After loading,
DataGridView
will populate data - The user will edit text from any cell
- After editing the text,
- Background color of the edited cell will change color to red,
- Only for the edited cell,
How can i change the background color of the edited cell in the DataGridView
?
This is what i tried by changing the background color of the cell.
private void Gridview_Output_CellBeginEdit_1(object sender, DataGridViewCellCancelEventArgs e)
{
DataGridViewCell cell = Gridview_Output[e.ColumnIndex, e.RowIndex];
cell.Tag = cell.Value != null ? cell.Value : "";
if (cell.OwningColumn.Name == "ValueOut")
cell.Style.BackColor = Color.Yellow;
}
global
List<DataGridViewCell> dgvc_List = new List<DataGridViewCell>();
Save button
private void btnSave_Click(object sender, EventArgs e)
{
dgvc_List.Add(cell);
foreach (DataGridViewCell d in dgvc_List)
{
d.Style.BackColor = Color.White;
}
dgvc_List.Clear();
}
Aucun commentaire:
Enregistrer un commentaire