我想请教个问题:怎样能够给DataGridView的第一列添加每行的名字,谢谢!

解决方案 »

  1.   

    bool isNullRow;
                for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                {
                    isNullRow = true;
                    foreach (DataGridViewCell cell in this.dataGridView1.Rows[i].Cells)
                    {
                        if (cell.EditedFormattedValue != null && string.IsNullOrEmpty(cell.EditedFormattedValue.ToString()) == false)
                        {
                            isNullRow = false;
                            break;
                        }                    
                    }
                    if (isNullRow)
                    {
                        //当前行所有列为空.
                    }
                }