I have a DataGridView. Some of the cells receive their data from a serial port: I want to shove the data into the cell, and have it update the underlying bound object.
If the DataGridView
has been populated by DataSource = x
(i.e. is databound) then you need to change the bound data, not the DataGridView cells themselves.
One way of getting to that data from a known row or column is thus:
(YourRow.DataBoundItem as DataRowView).Row['YourColumn'] = NewValue;
in VB you can use this one
Dim selectedRow As DataRowView
selectedRow = dg.Rows(dg.CurrentCell.RowIndex).DataBoundItem
selectedRow("MyProp") = "myValue"
dg.NotifyCurrentCellDirty(True)
thanks to saeed serpooshan for last row