DataGridView 行验证错误
我使用非常奇怪的方式将我的数据从网格同步到数据库:
例如:
#region Line methods
private void LinesView_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
{
lineTableAdapter.Update(fRIIBDataSet.Line);
}
private void LinesView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
lineTableAdapter.Update(fRIIBDataSet.Line);
}
private void LinesView_RowValidated(object sender, DataGridViewCellEventArgs e)
{
lineTableAdapter.Update(fRIIBDataSet.Line);
}
#endregion
但是当我将一些列切换到组合框时,我需要在更新之前做一些类似的事情:
private void dataGridView1_RowValidated(object sender, DataGridViewCellEventArgs e)
{
//deltaTableAdapter.Update(fRIIBDataSet.Delta); TODO
}
private void dataGridView1_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
{
deltaTableAdapter.Update(fRIIBDataSet.Delta);
}
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (lambdacat != null)
{
string selected = (LimView.Rows[e.RowIndex].Cells[1] as DataGridViewComboBoxCell).FormattedValue.ToString();
if (selected != "")
{
int find = Array.IndexOf(dict, dict.Where(x => x == selected).FirstOrDefault());
LimView.Rows[e.RowIndex].Cells[0].Value = dictiddarray[find];
//deltaTableAdapter.Update(fRIIBDataSet.Delta);
}
}
//deltaTableAdapter.Update(fRIIBDataSet.Delta);
}
取消注释更新方法后会出现麻烦。
当我打开带有表格的窗口时,我收到错误消息:内部索引 DataTable 已损坏:“5。”如何修复/避免此错误?
I'm sync my data from Grid to DataBase using really weird way :
for example :
#region Line methods
private void LinesView_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
{
lineTableAdapter.Update(fRIIBDataSet.Line);
}
private void LinesView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
lineTableAdapter.Update(fRIIBDataSet.Line);
}
private void LinesView_RowValidated(object sender, DataGridViewCellEventArgs e)
{
lineTableAdapter.Update(fRIIBDataSet.Line);
}
#endregion
but when I switched some columns to ComboBox I need to make some trick before Update alike that :
private void dataGridView1_RowValidated(object sender, DataGridViewCellEventArgs e)
{
//deltaTableAdapter.Update(fRIIBDataSet.Delta); TODO
}
private void dataGridView1_UserDeletedRow(object sender, DataGridViewRowEventArgs e)
{
deltaTableAdapter.Update(fRIIBDataSet.Delta);
}
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (lambdacat != null)
{
string selected = (LimView.Rows[e.RowIndex].Cells[1] as DataGridViewComboBoxCell).FormattedValue.ToString();
if (selected != "")
{
int find = Array.IndexOf(dict, dict.Where(x => x == selected).FirstOrDefault());
LimView.Rows[e.RowIndex].Cells[0].Value = dictiddarray[find];
//deltaTableAdapter.Update(fRIIBDataSet.Delta);
}
}
//deltaTableAdapter.Update(fRIIBDataSet.Delta);
}
troubles comes after uncommenting Update method.
When I opening the window with a table I've got error message : Damaged the internal index DataTable: "5. " How can I fix / avoid this error ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修改成这样有用吗?
Does modifying it to this work ?