471,605 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

DataGridView: Change the color of edited rows


I am working with the DataGridView control in a WinForm. I have written the
code to change the background color of a cell after it is edited. I also
change the color of the row (a different color) which allows users to see
what cells and which rows have been edited.

The problem is that whenever the user sorts the datagidview I lose the
coloration...how can I go about making sure that the cells remained colored?

private void dataGridView1_CellValueChanged(object sender,
DataGridViewCellEventArgs e)


for (int i = 0; i < dataGridView1.Rows[e.RowIndex].Cells.Count; i++)


if (dataGridView1.Rows[e.RowIndex].Cells[i].Style.BackColor !=


dataGridView1.Rows[e.RowIndex].Cells[i].Style.BackColor =



dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor =




Dec 29 '05 #1
0 3235

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Terry Olsen | last post: by
reply views Thread by =?Utf-8?B?S3VtYXIuQS5QLlA=?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.