DataGridView throwing “InvalidOperationException: Operation is not valid…” when adding a row

前端 未结 5 1618
失恋的感觉
失恋的感觉 2021-02-07 05:00

I want an OpenFileDialog to come up when a user clicks on a cell, then display the result in the cell.

It all works, except that the DataGridView displays an extra row,

5条回答
  •  孤街浪徒
    2021-02-07 05:40

    Remember to use Row.BeginEdit() and Row.EndEdit() if you get this error while editing a value in a row, using DataGrid or GridEX from Janus (in my case). The sample code that Darrel Lee posted here (https://stackoverflow.com/a/9143590/1278771) remind me to use these instructions that I forgot to use and this solved the problem for me.

提交回复
热议问题