int index = this.dataGridView1.CurrentCell.RowIndex;//获得焦点所在的行的索引
DataRow row = this.dataSet.Tables["Customer_tb"].Rows[index];// 获取表中当前行 
strselect = row[0].ToString();   //当前行的第一个值
editform neweditform = new editform();
neweditform.Show();
this.Visible = false;问题出在
DataRow row = this.dataSet.Tables["Customer_tb"].Rows[index];// 获取表中当前行 
请高人指点 谢谢

解决方案 »

  1.   

    dataGridView1 和 dataSet 行数和顺序不一致把,还有过滤过什么的
      

  2.   

    int index = this.dataGridView1.CurrentCell.RowIndex   执行有结果.
    而 DataRow row = this.dataSet.Tables["Customer_tb"].Rows[index]  没有结果.为null
    我很迷惑..
      

  3.   

    我是菜鸟,不过还是要说:
       dataGridView1和dataSet.Tables["Customer_tb"]访问的是同一个表么?
      

  4.   

    这句执行的结果是什么呢?
    //这句是获取DataGridView中数据表格的行号
    int index = this.dataGridView1.CurrentCell.RowIndex  执行有结果. //这句是获取数据源中的记录行
    DataRow row = this.dataSet.Tables["Customer_tb"].Rows[index];// 获取表中当前行 没看到DataSet数据绑定到DataGridView的代码。。
    DataSet获取数据之后,把数据源绑定到DataGridView,这样就是同一个数据源了,二者之一有数据那另外一个也就有数据了。