I have datagridview on my form and I want to allow user to add new row only if he fills up all cells in the previous one.
How I can do it?
I have datagridview on my form and I want to allow user to add new row only if he fills up all cells in the previous one.
How I can do it?
if your datagridview has no checkboxes or custom-made columns, you can just check at every step if all your fields from your last row are not null or empty, then make the AllowUserToAddRows = true
example:
bool all_fields_completed=true;
for(int i=0;i<mydatagrid.Columns.count;i++)
if(String.IsNullorEmpty(mydatagrid.Rows[mydatagrid.Rows.Count-1].Cells[i].Value.ToString()))
all_fields_completed=false;
if (all_fields_completed==true) mydatagrid.AllowUserToAddRows = true;
Click on your Datagridview --> Click Datagridview task --> and Check Enable Adding.
Regards