I have some empty datagridview which uses data source is List through BindingSource. Because AllowUserToAddRows = true, initially the datagridview has one empty row. When I just select this row and close the form then datagridview creates new empty object. Why it does it? How to prevent this? Thanks.
Selecting of empty row:
And I get this:

Conclusion: After many attempts to find a solution I decided to create UI control with datagridview and two buttons (add row and delete row). At this point I stopped trying to do as planned, but I'd still be pleased to know solutions.
You can handle RowValidating event to verify if row is empty. If so, then cancel event and row will not be added.
if (gridView[0, e.RowIndex].Value == null)
e.Cancel = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With