DataTable internal index is corrupted

前端 未结 18 1456
轻奢々
轻奢々 2020-12-04 15:55

I am working with a .NET WinForms app in C#, running against the 3.5 .NET framework. In this app, I am setting the .Expression member of a DataColumn in a

18条回答
  •  春和景丽
    2020-12-04 16:36

    Here is what seems to have worked for my colleague Karen and I. We were getting this error in a DataGridView, but only when entering data into one particular column.

    It turns out that I had changed the order of columns in the grid, not knowing that there was code in the DataGridView.CellValidated sub that nulls out the value in that one particular column causing the problem.

    That code referred to a specific column number. So when the original DataGridView column 3 was moved and became column 1, but the DataGridView.CellValidated code still referred to column 3, the error occurred. Changing our code so that it referred to the correct e.ColumnIndex seems to have fixed our problem.

    (It was not easy to figure out to change this one number in our code. I hope this fix holds.)

提交回复
热议问题