I have a Winform datagridview, which is bind to a datatable. After loading the grid, I assign for every row an associated object to the Tag property. The problem is now. that after some actions/clicks all Tag properties are NULL again. The cell values are still there. What could be the reason for that?
1
votes
2 Answers
3
votes
The issue you're describing may be due to the way DataGridView attempts to "share" rows to conserve memory. You can read more about the behavior here: http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx
Various programmatic and user actions can cause a row to become unshared. From the docs it appears that this causes a new (unshared) row to be created. If all of the rows were maintained as individual objects in the grid, you could potentially have significant performance issues.
Can you set the associated object on the underlying data item that the row is bound to?