在我的WinForms项目中,有一个绑定到BindingSource的DataGridView。 DataGridview由表单设计器生成。我将SQL表与Entity Framework绑定在一起,如下所示:
public void onBackPressed(){
Fragment fragment=getSupportFragmentManager().findFragmentByTag(/*enter your tag*/);
if(fragment!=null && fragment.isVisible())
{
//do your code here
}
else
{
//do your code here
}
}
DataGridView显示正确的数据,没有任何问题。但是,在用户编辑单元格之后,将引发以下异常。
IQCDB.Measurement.Where(x => x.component_id == openTag.ID).Load();
measurementBindingSource.DataSource = IQCDB.Measurement.Local.ToBindingList();
编辑哪一列都没关系。输入无效值将按原样触发DataError。输入有效值还会触发DataError,然后触发先前描述的异常。有趣的是,尝试从DataGridView中删除一行会导致相同的Exception,但是报告的参数名称为“ Index”。
这是我要更改的表的架构:
Database table schema
这是堆栈跟踪:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: rowIndex
感谢所有帮助。如果需要,只需询问更多具体信息。