Get method parameters from throwing method in C #

I have a nasty exception that seems to occur deep inside the DataGridView code.

I have a class that inherits from BindingList, which is a data source of BindingSource, which is a DataSoure DataGridView.

In some strange circumstances, I get an exception during the overridden OnListChanged () method of my class:

    protected override void OnListChanged(ListChangedEventArgs e)
    {
        base.OnListChanged(e); // <-- ArgumentOutOfRangeException
                               // ...Parametername: rowIndex
    }

stacktrace is as follows:

    bei System.Windows.Forms.DataGridView.GetCellDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow)
    bei System.Windows.Forms.DataGridView.GetCellAdjustedDisplayRectangle(Int32 columnIndex, Int32 rowIndex, Boolean cutOverflow)
    bei System.Windows.Forms.DataGridView.InvalidateCellPrivate(Int32 columnIndex, Int32 rowIndex)
    bei System.Windows.Forms.DataGridView.OnCellCommonChange(Int32 columnIndex, Int32 rowIndex)
    bei System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
    bei System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
    bei System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
    bei System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
    bei System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
    bei System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)
    bei System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
    bei System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
    bei My.Own.BindingList.OnListChanged(ListChangedEventArgs e)

Well, I could just add a try \ catch exception, but I'm curious why this happens at all.

- , System.Diagnostics.StackTrace, StackFrame, ( ) ( , ), , , rowindex/columnindex, .

- , , ?

!

:

, , rowIndex. BindingList - DataGridView. , OnListChanged, , dataGridView T. getter , , - OnPropertyChanged T-.

(this) BindingList Add, : - BindingList <T> ? . ; (

+3
2

( ), , , , . StackTrace , , , , .

, . , . . , , Debugger.Break() (, , , ), .

IDE , , , ( , , , IDE).

, , , , IDE, . , , , , , , .

+2
+1

Source: https://habr.com/ru/post/1724721/


All Articles