473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DataGridView: Change the color of edited rows

RSH

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 !=
Color.Moccasin)

{

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

}

}

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

}

Thanks,

Ron


Dec 29 '05 #1
0 3297

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Arvind | last post by:
Hi I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try...
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
3
by: steve | last post by:
Hi All How can I get the datagridview to redraw after changing the rowtemplate.height at runtime ( it is databound to a datatable) I have tried datagridview1.refresh etc to no avail (The row...
0
by: MKBender | last post by:
Hello everyone, What I'm currently trying to do is allow a user to add a row to my datagridview. I have AllowUserToAddRows set to true. And the empty now does appear at the bottom of my data. ...
5
by: DanThMan | last post by:
The situation: * I have a ButtonColumn in a DataGridView. * When the user preses one of the buttons, a dialog appears. * Based on what the user selects in the dialog, data is entered...
4
by: Terry Olsen | last post by:
How can i tell if a row in my DataGridView has been edited? I'm loading a DataTable with ID3 information from MP3 files and using that as the datasource for the DataGridView. I'm letting the user...
0
by: RickH | last post by:
Has anyone tried wrapping the DataGridView control itself as a custom Cell/Column control. So that I can have a child DataGridView appear in a column of a parent DataGridView so that the...
0
by: =?Utf-8?B?S3VtYXIuQS5QLlA=?= | last post by:
I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try to...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.