-
Notifications
You must be signed in to change notification settings - Fork 958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataGridView filter caused IndexOutOfRangeException #4216
Comments
Please provide a simple repro. |
@coderb are you using accessibility tools, like Inspect or Narrator?
@vladimir-krestov @SergeySmirnov-Akvelon please check this call stack. |
I can't repro it currently but if I can I will post. Perhaps there is some kind of race with the Paint event. |
no |
i found a similar error when user does the following steps:
Note:
|
This submission has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days. It will be closed if no further activity occurs within 7 days of this comment. |
During investigation, we discovered several details:
|
This suggestions look reasonable. Let's get it fixed and look at any perf implications then. |
to DataGridView and BindingNavigator. Fixes dotnet#4216 A DataGridView threw IndexOutOfRangeException when its DataSource is already disposed and the DataGridView try to redraw itself, because its Rows and Columns are not updated but DataSource is already released. The DataGridView try to draw rows that are not exist in DataConnection, it send some index (eg. 5) to items collection and catch the exception because this index is out of empty items collection range. Initially, the issue repoduced when a user closes a form with DataGridView and BindingNavigator, because the form disposes BindingSource when closing and then disposes BindingNavigator, that try to redraw DataGridView. It is due to BindingNavigator send UiaReturnRawElementProvider message to Windows and it redraws DGV sometimes (looks like a bug). We tried to cancel DGV redwawing if a form is closing. Then we found the second case: we cought this IndexOutOfRangeException if to just dispose DataSource without form closing. So the issue is DataGridView Rows and Columns are not updated when DataSource disposing. This fix uses Dispose events to set null for DataGridView.DataSource and BindingNavigator.BindingSource thereby call refresh of internal collections of their items.
…taSource (#4551) to DataGridView and BindingNavigator. Fixes #4216 A DataGridView threw IndexOutOfRangeException when its DataSource is already disposed and the DataGridView try to redraw itself, because its Rows and Columns are not updated but DataSource is already released. The DataGridView try to draw rows that are not exist in DataConnection, it send some index (eg. 5) to items collection and catch the exception because this index is out of empty items collection range. Initially, the issue repoduced when a user closes a form with DataGridView and BindingNavigator, because the form disposes BindingSource when closing and then disposes BindingNavigator, that try to redraw DataGridView. It is due to BindingNavigator send UiaReturnRawElementProvider message to Windows and it redraws DGV sometimes (looks like a bug). We tried to cancel DGV redwawing if a form is closing. Then we found the second case: we cought this IndexOutOfRangeException if to just dispose DataSource without form closing. So the issue is DataGridView Rows and Columns are not updated when DataSource disposing. This fix uses Dispose events to set null for DataGridView.DataSource and BindingNavigator.BindingSource thereby call refresh of internal collections of their items.
@coderb how severely does this issue impact you? |
@RussKie i've delayed upgrading to 5.0 (still on 3.1) due to it. it would be great if it landed in a production release sooner rather than later! |
…taSource (dotnet#4551) to DataGridView and BindingNavigator. Fixes dotnet#4216 A DataGridView threw IndexOutOfRangeException when its DataSource is already disposed and the DataGridView try to redraw itself, because its Rows and Columns are not updated but DataSource is already released. The DataGridView try to draw rows that are not exist in DataConnection, it send some index (eg. 5) to items collection and catch the exception because this index is out of empty items collection range. Initially, the issue repoduced when a user closes a form with DataGridView and BindingNavigator, because the form disposes BindingSource when closing and then disposes BindingNavigator, that try to redraw DataGridView. It is due to BindingNavigator send UiaReturnRawElementProvider message to Windows and it redraws DGV sometimes (looks like a bug). We tried to cancel DGV redwawing if a form is closing. Then we found the second case: we cought this IndexOutOfRangeException if to just dispose DataSource without form closing. So the issue is DataGridView Rows and Columns are not updated when DataSource disposing. This fix uses Dispose events to set null for DataGridView.DataSource and BindingNavigator.BindingSource thereby call refresh of internal collections of their items. (cherry picked from commit 3f9c8e7)
We've got an approval to service this in 5.0.5 |
fantastic, thank you! |
…osed (servicing) (#4637) to DataGridView and BindingNavigator. Fixes #4216 A DataGridView threw IndexOutOfRangeException when its DataSource is already disposed and the DataGridView try to redraw itself, because its Rows and Columns are not updated but DataSource is already released. The DataGridView try to draw rows that are not exist in DataConnection, it send some index (eg. 5) to items collection and catch the exception because this index is out of empty items collection range. Initially, the issue repoduced when a user closes a form with DataGridView and BindingNavigator, because the form disposes BindingSource when closing and then disposes BindingNavigator, that try to redraw DataGridView. It is due to BindingNavigator send UiaReturnRawElementProvider message to Windows and it redraws DGV sometimes (looks like a bug). We tried to cancel DGV redwawing if a form is closing. Then we found the second case: we cought this IndexOutOfRangeException if to just dispose DataSource without form closing. So the issue is DataGridView Rows and Columns are not updated when DataSource disposing. This fix uses Dispose events to set null for DataGridView.DataSource and BindingNavigator.BindingSource thereby call refresh of internal collections of their items. (cherry picked from commit 3f9c8e7) Co-authored-by: vladimir-krestov <49272759+vladimir-krestov@users.noreply.github.com>
Verified the issue with latest 6.0.100-preview.3.21169.6, the issue has been fixed that no exception ops up for now. |
.NET Core Version: .NET 5.0.100
Have you experienced this same bug with .NET Framework?:
No
Problem description:
I have a
DataGridView
with aDataView
data source that I use the set aRowFilter
. It mostly works, but I just got the following stack (with a Dialog popup). I've never seen this prior to .net 5.0.The text was updated successfully, but these errors were encountered: