.netwinformsdatagridviewediting

Why can't I edit the values in my DataGridView, even though its not set to ReadOnly?


I have a DataGridView, which is not set to ReadOnly. None of its columns are set to ReadOnly, and the object it is bound to is not set to ReadOnly. Yet, I can't edit the DataGridView items? The .DataSource property of the DataGridView is set to a ReadOnlyCollection<>, but I can programmatically alter the elements, just not from the UI. What's going on?


Solution

  • It turns out that if your DataGridView is bound to a ReadOnlyCollection, then even though you can programatically edit any item in the collection, the DataGridView will restrict you from changing the values. I'm not sure if this behavior is intentional, but its something to watch out for.