도움이 필요합니다. BindingList에 읽기 전용으로 바인딩되는 DataGridView가 있습니다. 먼저 새 목록에 대한 데이터 소스를 설정하고 항목을 목록에 추가합니다. 열이 자동으로 생성됩니다. 페이지를 새로 고침해야 할 때 목록을 지우고 항목을 다시 추가하면됩니다.BindingList.Clear 수행으로 인해 DataGridView가 발생합니다. System.IndexOutOfRangeException
나는 그것이 잘 작동하지만 작업을 시작하고는 바인딩에 지우기()를 호출, 그것을 할 경우 예외로 실패 UI와 페이지 동기화 다시로드를 수행하는 경우 :
System.IndexOutOfRangeException was unhandled
HResult=-2146233080
Message=Index 0 does not have a value.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at InCare.UserControls.DataGridViewItemWrapper.DataGridViewOnRowsAdded(Object sender, DataGridViewRowPostPaintEventArgs args) in C:\ws\Source\Repos\incare\Src\InCare.UserControls\DataGridViewItemWrapper.cs:line 40
at System.Windows.Forms.DataGridViewRowPostPaintEventHandler.Invoke(Object sender, DataGridViewRowPostPaintEventArgs e)
at System.Windows.Forms.DataGridView.OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded)
at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
'BindingList'이 스레드 안전하지 않습니다. 그것이 실패하는 이유입니다. –