1

I am looking to modify a DataRowView value from an event.

I have tried the following but it never changes the DataGridCheckBoxColumn

((DataRowView)repDataGrid.SelectedItem).Row.ItemArray[4] = true;
J. Steen
  • 15,470
  • 15
  • 56
  • 63
ullevi83
  • 199
  • 2
  • 17
  • possible duplicate [Set value to a DataRow automatically](https://stackoverflow.com/questions/26232466/c-sharp-set-value-to-a-datarow-automatically) – Kaj Jun 15 '18 at 11:26

1 Answers1

3

ItemArray creates a new object[] which can be used to read the values. But you can't use it to set them. You can use the DataRow indexer:

((DataRowView)repDataGrid.SelectedItem).Row[4] = true;

If you wanted to use ItemArray to assign the values you have to re-assign it:

DataRow row = (DataRowView)repDataGrid.SelectedItem).Row;
object[] fields = row.ItemArray;
fields[4] = true;
row.ItemArray = fields;
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939