I’ve datagridview in my windows application. By default the datagridview loads with 1 row. If we type something in the cell it creates another row below this row. It goes on like this. Now if someone types something and then deletes it, the row created below doesn’t get deleted. I want to stop user from creating unlimited no. of rows without any data. Is it possible to restrict the datagridview to create maximum 2 such blank rows? Please suggest, how it can be done.
I’ve datagridview in my windows application. By default the datagridview loads with 1 row.
Share
It cannot be achieved automatically. You will need to do that manually. The best way to that is properly handling of cellvalidating and cellvalidated event. And cancel event if cells are empty. You can also set property AllowUserToAddRows=false and manually add new row e.g. by pressing button: