DataGridView AllowUserToAddRows

If you set the datagridview.allowuseraddrows = true, then there will be a row with value null, and then when you traversal the rows of the datagridview.rows[X].cells[Y].value, there will be a exception, nullreferenceexception.

Keep in mind that, if you don't  want the user to add row, set the allowuseraddrows to false, then the datagridview will be more safe, either when you get the value or other operators.

原文地址:https://www.cnblogs.com/henyihanwobushi/p/2972422.html