hi,
i need to update/refresh single row in the grid.
i see that the Row has a Refresh method. that is good.
The only piece i am missing, is how to swap a new object to re-bind this row to.
i see that the row has ListObject property, but that is read only.
I basically need a way to
1. update that ListObject property
2. refresh appropriate row
the one way i can think of doing this is,
myObjects = myGrid.DataSource as IEnumerable<MyObject>
<replace object in collection>
myGrid.DataSource = myObjects
MyGrid.Rows[x].Refresh(...)
I am not sure this will work correctly, and hoping there is a better way.
What kind of DataSource are you using for the grid? If you are using any robust data source which implements IBindingList, then you could simply remove the row and insert a new row into the same position and you would not even need to call Refresh on the grid row, because the data source would notify the grid of the change.
yep,
my solution works.
just have to be mindful of Row.Index (visible index) vs Row.ListIndex (index of the underlying object in the array)
that's what caused me to waste a little time figuring out why wrong items were refreshed.