如何判断datagridview的单元格是否为空?

解决方案 »

  1.   

     this.dataGridView1.Rows[i].Cells[i].Value = null;
      

  2.   

    this.dataGridView1.Rows[i].Cell[i].Text.ToString()="";
      

  3.   

    if(this.dataGridView1.Rows[i].Cells[i].Value == null)
    {
        //do something 
    }
      

  4.   

    1、如果当前的DataGridView允许新增行或可编辑的话
    if (this.dataGridView1.CurrentCell.EditedFormattedValue.ToString()!=string.Empty)
    {
      //do something
    }2、不可编辑的DataGridView
    if (this.dataGridView1.CurrentCell.Value.ToString()!=string.Empty)
    {
      //do something
    }

    if (this.dataGridView1.CurrentRow!=null) 
    if (this.dataGridView1.CurrentRow.Cell[i].Value.ToString()!=string.Empty)
    {
      //do something
    }
      

  5.   

    不行呀,我是想在读datagridview表格时,如何判断是否存在空的单元格?想用一个if语句,怎么写代码呢,
    请老师指点呀!!!
      

  6.   

    this.dataGridView1.Rows[i].Cell[i].Text.ToString().Equals("") || this.dataGridView1.Rows[i].Cell[i].Text.ToString().Equals(" ")
      

  7.   

    if (GridView.Rows[i].Cell[i].Text.ToString()== "")
    (
    )当然首先要保证这个GridView已经打到前台了。
      

  8.   

    if(this.dataGridView1.Rows[i].Cells[i].Value = null||this.dataGridView1.Rows[i].Cells[i].Value==String.Empty)
    {}