コードに以下のロジックがあります。
Initialize(){
DataGridView view = new DataGridView();
view.BindingSource = bs;
bs.dataSource = dataTable;
//Fill Data Table using Adapter.
da.fill(dataTable);
}
CallMeEveryFewMinutes(DataTable dataTable){
List<String> changed = findChangedOjbects();
// Fill datatable2 with changed objects.
da2.fill(datatable2, changed)
Refresh(dataTable, datatable2);
// dataTable is now refreshed. Bind it again so changes are reflected.
// ********** PROBLEM AREA ***************
// once in a while it throws the below exception.
bs.dataSource = dataTable;
}
それだけでなく、datagridview.sort(...) に対しても同じ例外をスローします - たまに ..
どんな指針も本当に役に立ちます。
System.Reflection.TargetInvocationException: 呼び出しのターゲットによって例外がスローされました。---> System.ArgumentOutOfRangeException: 指定された引数が有効な値の範囲外でした。パラメーター名: System.Windows.Forms.DataGridView.GetCellDisplayRectangle の rowIndex(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow) System.Windows.Forms.DataGridView.GetCellAdjustedDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow) at System.Windows.Forms .DataGridView.InvalidateCellPrivate(Int32 columnIndex, Int32 rowIndex) System.Windows.Forms.DataGridView.OnCellCommonChange(Int32 columnIndex, Int32 rowIndex) で System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e) で System.Windows.Forms .DataGridView.