Skip to content

DataGridView filter caused IndexOutOfRangeException #4216

@coderb

Description

@coderb
  • .NET Core Version: .NET 5.0.100

  • Have you experienced this same bug with .NET Framework?:
    No

Problem description:
I have a DataGridView with a DataView data source that I use the set a RowFilter. It mostly works, but I just got the following stack (with a Dialog popup). I've never seen this prior to .net 5.0.

Popup: DataGridView Default Error Dialog
The following exception occurred in the DataGridView:
System.IndexOutOfRangeException: Index 1 does not have a value.
at System.Windows.Forms.CurrencyManager.get_Item(Int32 index)
at System.Windows.Forms.DataGridView.DataGridViewConnection.GetError(Int32 rowIndex)
 	[Managed to Native Transition]	
 	System.Windows.Forms.Primitives.dll!Interop.User32.MessageBoxW(System.Runtime.InteropServices.HandleRef hWnd, string lpText, string lpCaption, Interop.User32.MB uType)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.MessageBox.ShowCore(System.Windows.Forms.IWin32Window owner, string text, string caption, System.Windows.Forms.MessageBoxButtons buttons, System.Windows.Forms.MessageBoxIcon icon, System.Windows.Forms.MessageBoxDefaultButton defaultButton, System.Windows.Forms.MessageBoxOptions options, bool showHelp) Line 413	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnDataError(bool displayErrorDialogIfNoHandler, System.Windows.Forms.DataGridViewDataErrorEventArgs e) Line 14636	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnDataErrorInternal(System.Windows.Forms.DataGridViewDataErrorEventArgs e) Line 14650	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(int rowIndex) Line 1193	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.GetErrorText(int rowIndex) Line 1221	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle rowBounds, int rowIndex, System.Windows.Forms.DataGridViewElementStates rowState, bool isFirstDisplayedRow, bool isLastVisibleRow) Line 1402	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.PaintRows(System.Drawing.Graphics g, System.Drawing.Rectangle boundingRect, System.Drawing.Rectangle clipRect, bool singleHorizontalBorderAdded) Line 19610	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.PaintGrid(System.Drawing.Graphics g, System.Drawing.Rectangle gridBounds, System.Drawing.Rectangle clipRect, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded) Line 19482	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnPaint(System.Windows.Forms.PaintEventArgs e) Line 16607	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs e, short layer) Line 8621	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmPaint(ref System.Windows.Forms.Message m) Line 12345	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 12741	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.WndProc(ref System.Windows.Forms.Message m) Line 29102	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 115	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 372	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Windows.Forms.Primitives.dll!Interop.UiaCore.UiaHostProviderFromHwnd(System.Runtime.InteropServices.HandleRef hwnd, out Interop.UiaCore.IRawElementProviderSimple ppProvider)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlAccessibleObject.HostRawElementProvider.get() Line 537	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Windows.Forms.dll!System.Windows.Forms.AccessibleObject.RaiseAutomationEvent(Interop.UiaCore.UIA eventId) Line 1949	C#
>	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewCell.DataGridViewCellAccessibleObject.SetFocus() Line 594	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.AccessibilityNotifyCurrentCellChanged(System.Drawing.Point cellAddress) Line 54	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick) Line 26233	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress(int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick, bool clearSelection, bool forceCurrentCellSelection) Line 26596	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewDataConnection.MatchCurrencyManagerPosition(bool scrollIntoView, bool clearSelection) Line 1336	C#
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_PositionChanged(object sender, System.EventArgs e) Line 803	C#
 	System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnPositionChanged(System.EventArgs e) Line 971	C#
 	System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) Line 742	C#
 	System.Data.Common.dll!System.Data.DataView.OnListChanged(System.ComponentModel.ListChangedEventArgs e) Line 1434	C#
 	System.Data.Common.dll!System.Data.DataView.UpdateIndex(bool force, bool fireEvent) Line 1634	C#
 	System.Data.Common.dll!System.Data.DataView.SetIndex2(string newSort, System.Data.DataViewRowState newRowStates, System.Data.IFilter newRowFilter, bool fireEvent) Line 1559	C#
 	System.Data.Common.dll!System.Data.DataView.SetIndex(string newSort, System.Data.DataViewRowState newRowStates, System.Data.IFilter newRowFilter) Line 1538	C#
 	System.Data.Common.dll!System.Data.DataView.RowFilter.set(string value) Line 337	C#
 	myapp.dll!myapp.MyDataView.SetRowFilter(string value) Line 64	C#
 	myapp.dll!myapp.MyDataGridViewContextMenu.miFilterFieldAdd_Click(object sender, System.EventArgs e) Line 293	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStripMenuItem.OnClick(System.EventArgs e) Line 898	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleClick(System.EventArgs e) Line 2397	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleMouseUp(System.Windows.Forms.MouseEventArgs e) Line 2579	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.OnMouseUp(System.Windows.Forms.MouseEventArgs mea) Line 3667	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStripDropDown.OnMouseUp(System.Windows.Forms.MouseEventArgs mea) Line 1357	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) Line 12106	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 12885	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Line 1457	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.WndProc(ref System.Windows.Forms.Message m) Line 4848	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ToolStripDropDown.WndProc(ref System.Windows.Forms.Message m) Line 2098	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 115	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 372	C#
 	[Native to Managed Transition]	

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions