Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2925
Infragistics.Shared.DisposableObject.VerifyNotDisposed() on Bands(i).SortedColumns.Clear()
posted

We have a issue where we are opening a grid. We have overridden the grid_AfterSortChange event where we are running the following code:

Private Sub grid_AfterSortChange(ByVal sender As Object, ByVal e As BandEventArgs) Handles MyBase.AfterSortChange
     ' Is grid setting requires it, perpetuate sortedcloumns down the bands
     Try
 
         If Me.IsUpdating Then Exit Sub
 
         If Me._bCascadeSorting AndAlso e.Band.Index = 0 AndAlso Me.DisplayLayout.Bands.Count > 1 Then
             For i As Integer = 1 To Me.DisplayLayout.Bands.Count - 1
                 With Me.DisplayLayout.Bands(i)
                     .SortedColumns.Clear()
                     For Each col As UltraGridColumn In e.Band.SortedColumns
                         If Not col.IsGroupByColumn AndAlso .Columns.Exists(col.Key) Then
                             .SortedColumns.Add(col.Key, col.SortIndicator = SortIndicator.Descending)
                         End If
                     Next
                 End With
             Next
         End If


However at the point we call Me.DisplayLayoput.Bands(i).SortedColumns.Clear() we get the following stack trace:

Error in tfUltraGrid_AfterSortChange.: Cannot access a disposed object.
Object name: 'Infragistics.Win.UltraWinGrid.UltraGridColumn'.

Exception StackTrace:

at Infragistics.Shared.DisposableObject.VerifyNotDisposed()
at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger)
at Infragistics.Win.UltraWinGrid.UltraGridColumn.InternalSetSortIndicator(SortIndicator sortIdicator)
at Infragistics.Win.UltraWinGrid.SortedColumnsCollection.InternalClear()
at Infragistics.Win.UltraWinGrid.SortedColumnsCollection.ApplyNewSortedColumns(SortedColumnsCollection newSortedColumns, Boolean groupBy)
at Infragistics.Win.UltraWinGrid.SortedColumnsCollection.ProcessNewSortedColumnsHelper(SortedColumnsCollection newSortedColumns, Boolean fireEvents, Boolean groupBy)
at Infragistics.Win.UltraWinGrid.SortedColumnsCollection.Clear()
at thinkFolio.tFUltraGrid.grid_AfterSortChange(Object sender, BandEventArgs e)


Is there any particular reason we would be getting this error as it suggestions that we are trying to access a grid column that has been disposed. We are only opening a grid view.

  • 34790
    Offline posted

    Hello Campbell,

    I have been investigating into the behavior you are seeing, but have not yet been able to reproduce it. What is the operation that is causing this exception to occur or more specifically, what operation that causes the AfterSortChange event to fire leads to this exception?

    I also find it rather strange that the call to SortedColumns.Clear is happening prior to trying to loop e.Band.SortedColumns, as this should empty that collection and will also likely fire the AfterSortChange event again, so you may need a check or try unhooking and re-hooking the event to ensure that it doesn’t try to get into this event’s logic twice.

    Do you have an isolated sample project that you can attach that reliably reproduces the behavior you are seeing?