0

I currently have a DataGridView that is bound to a DataSet reading from an XML file.

Populating the DataGridView just fine; the last column is a button I want the user to click to commit changes to the row.

I'm able to find which rows are dirty easily, however, I'm having trouble finding which cells within a dirty row are themselves dirty.

I iterated through each cell within a dirty row, but they're not showing as being dirty.

Any thoughts appreciated!

if ( this.inventoryGridView.Columns[e.ColumnIndex].Name == "itemCheckedIn" )
        {
            // Give the user a visual indicator the cells are "locked"/readonly by changing the background color
            this.inventoryGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightGray;

            // Check if any changes have been made to the row that was checked in
            if ( this.inventoryGridView.IsCurrentRowDirty )
            {
                foreach ( DataGridViewCell dirtyBoy in this.inventoryGridView.CurrentRow.Cells )
                {
                    // Is he dirty?
                }
            }

            // No changes were made to the row that was check in; let's log the check in
            else
            {
                // Log the check in time
            }
Jimmerz28
  • 1,095
  • 8
  • 12

1 Answers1

0

You can try this:

  1. Add a hidden column to your gridView
  2. On change of any value to a cell in the row, bind to a javascript function
  3. On change of a value, write the cell number to the hidden column as a comma delimited value, for example: 1, 3, 5 cell numbers were changed
  4. You can then use the hidden column value to create an array and know exactly which cells changed in a row.
Divi
  • 7,621
  • 13
  • 47
  • 63
  • Thanks Divi that was going to be my last resort, however, I wanted to check first and see if there was a proper way of getting the dirty cells. Roundabouts always give me a chill >. – Jimmerz28 Jan 18 '11 at 14:49
  • I couldn't think of any other way of doing this. I know its a hack but.....I don't know if you could add a "dirty" class to your on change and see if that helps. – Divi Jan 19 '11 at 00:02