How to check empty and null cells in datagridview using C#

前端 未结 8 2460
太阳男子
太阳男子 2020-12-17 15:02

i am trying to check the datagridview cells for empty and null value... but i can not do it right...

for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
         


        
8条回答
  •  萌比男神i
    2020-12-17 15:36

    if (!GridView1.Rows[GridView1.CurrentCell.RowIndex].IsNewRow)
    {
         foreach (DataGridViewCell cell in GridView1.Rows[GridView1.CurrentCell.RowIndex].Cells)
        {
            //here you must test for all and then return only if it is false
            if (cell.Value == System.DBNull.Value)
            {
                return false;
            }
        }
    }
    

提交回复
热议问题