Search code examples
c#datagridviewrow

Datagridview new row disappear


in my DataGridView I click on a new row, then new empty row appears at the bottom, it is standard behaviour and there is no problem. So I fill the row and click on the last empty row and here is the problem, the row I just filled disappears. Cells in datagridview are of different types textbox, datagridviewcombobox, date, int. I catch DataError event and there is no error message.

Thats the way I set the data source DataGridView.DataSource=dataTable;

I can not find the reason why this happens. I found that one of the reasons could be because entered data are not valid but as far as I am convinced this should not be my case, but maybe I am wrong.


Solution

  • I just solved it myself and I hope it will help somebody else because I did not find many references concerning this.

    Finally it really was a problem of data entered into new row. They was correctly entered so there was no error message BUT there was some columns missing (I mean columns that are not visible to the user) and that was a reason why the newly entered row disappeared. So I used event DefaultValuesNeeded, entered all 13 columns, and it works now as expected, I just must tune now which columns to enter by user and which by code.

    Best regards