I want to check if my “many” column in datagridview is empty.
here my code
for (int i = 0; i < (gridx.Rows.Count - 1); i++)
{
col = gridx.Rows[i].Cells["code"].Value.ToString();
col4 = gridx.Rows[i].Cells["many"].Value.ToString();
}
if (col4 == "")
{
MessageBox.Show("Many is empty");
this.Focus();
return;
}
else
{
//my code in here
}
but it don’t show error “many is empty”
please help me.. and thanks before
Since you are assigning the last cell value to
col4in your for loop, you may check it against null.Your current code will only check if the last row of the
cell["many"]is empty. If you want make sure that all the columns is empty then you may try the following approach.now check if the isColumnEmpty flag got set;