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
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)
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?