dataGridView中有很多空行 如何返回非空的行数
dataGridView1.Rows.Count?

解决方案 »

  1.   

    for循环 统计 
    判断每行的 每列是否全为空
    不为空则统计数加1最后返回统计数
      

  2.   

    int count=0;
    for(int i=0;i<this.dataGridView1.Rows.Count;i++)
    {
       if(this.dataGridView1.Rows[i].Cells[0].Value.ToString()!="")
       {
         count++;
       }
    }count就是dataGridView1返回非空的行数
      

  3.   

    判断dataGridView1绑定的数据源的行数可能简单些
      

  4.   

    for循环是一个很常用的方法,楼主不能怕麻烦。
      

  5.   

    或者说先删除dataGridView1上面的空白行再
    读取它的dataGridView1.Rows.Count?
      

  6.   

    dataGridView中有很多空行 ------------------------------为什么会有很多空行? 你不知道在查询时 把空行都删了?
      

  7.   

    你是使用DATASOURCE绑定的吗?删除DATASOURCE的空行在刷新就行啦?
      

  8.   

    如果datasource不可用。就只能遍历一次了。
      

  9.   

    禁止空行AllowNewRow   =   false; 
    遍历判断
      

  10.   

    ((DataTable) dataGridView1.DataSource) .Select("列一 <> ''").Length.ToString()
      

  11.   

    DataTable dt=(DataTable)dataGridView1.DataSource;
    int count=dt.rows.count;