未将对象引用设置到对象实例。提示错误是这行代码: int rowindex = dataGridView1.CurrentCell.RowIndex;

解决方案 »

  1.   

    dataGridView1.CurrentCell.RowIndex   应该是一个空值    我建议 楼主设置断点 调试一下。
     这个问题 不是很复杂     只要你会调试  就能很快解决
      

  2.   

    int rowindex =dataGridView1.CurrentCell==null?0: dataGridView1.CurrentCell.RowIndex;
      

  3.   

    试试判断是不是新行
    if (this.dataGridView1.NewRowIndex != this.dataGridView1.CurrentRow.Index&&dataGridView1.CurrentCell.Value!=null)
      

  4.   

    你将这个代码放在了Cell操作之前了,当然不对。
      

  5.   

    不行,如果按你这个做,那么就会出现,当前上下文中不存在名称rowindex了。
      

  6.   

    加个判断就行,断点跟踪进去就知道那个对象为null了