datagridview1 里1:有 A , B 两个域2:没有绑定数据源3:datagridview1 启用添加 运行后 我往里面添加了记录
有个按钮点击事件里
string ls="";
if (dataGridView1.Rows.Count > 0) for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
ls += dataGridView1.Rows[i].Cells["A"].Value.ToString().Trim(); }
ls += dataGridView1.Rows[i].Cells["A"].Value.ToString().Trim();
这句报错:未处理 System.NullReferenceException{"未将对象引用设置到对象的实例。"}
有个按钮点击事件里
string ls="";
if (dataGridView1.Rows.Count > 0) for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
ls += dataGridView1.Rows[i].Cells["A"].Value.ToString().Trim(); }
ls += dataGridView1.Rows[i].Cells["A"].Value.ToString().Trim();
这句报错:未处理 System.NullReferenceException{"未将对象引用设置到对象的实例。"}
string ls="";
if (dataGridView1.Rows.Count > 0) for (int i = 0; i < dataGridView1.Rows.Count -1; i++)
{
ls += dataGridView1.Rows[i].Cells["A"].Value.ToString().Trim(); }for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
有新行 要减 1