Operation cannot be performed on a shared row

On http://msdn.microsoft.com/en-us/library/ha5xt0d9.aspx one finds some good advises on how to use Dotnet’s DataGridView with large data.  Amongst others one is told to care about Shared Row for data reuse.

A solution of mine was to populate the grid with objects of my own creation and then call SetValues; but when I refactored my solution and put the calls in the “right place” I got an InvalidOperationException exception with the message “Operation cannot be performed on a shared row.”

The SetValues call was made from a class that inherited DataGridViewRow.  The solution was to move the call out of the class (to my class that inherited the UserControl).

This article might hopefully help someone in the future with the same problem.


6.5 years later and no comment shows that I probably was alone with this problem. Or that my site doesn’t rate high enough.

Leave a Reply