I am using ultragrid control with checkbox and We provided radio button for applying a filter for the showing "selected checkbox row" or "all row".For Filter, we wrote following VB.NET code. We use Grid with row header checkbox and Grid Header checkbox.
So ModifyGridRowsShown called by two thread.
1.UI Thread(Main Thread).
Problem: When I call this function with UI Thread its work fine but when I called This from Background Thread its throw exception "Index Out of Bound" and display RED X.
This exception occurs sometime not regularly and I am not able to catch this exception on TRY...Catch block as well as on UltrGrid.Error event.
Public Overrides Sub ModifyGridRowsShown(ByVal filter As Boolean)
If Me.grdResult.Rows.Count > 0 Then
Dim row As UltraGridRow = Nothing
For Each row In grdResult.Rows
If Not Nothing Is row.ChildBands Then
' Loop throgh each of the child bands.
Dim childBand As UltraGridChildBand = Nothing
For Each childBand In row.ChildBands
Dim i As Integer
For i = 0 To childBand.Rows.Count - 1
If filter Then
If Not DirectCast(childBand.Rows(i).Cells(0).Value, Boolean) Then
childBand.Rows(i).Hidden = True
childBand.Rows(i).Hidden = False
If Not filter Then
row.Hidden = False
Thank you for contacting Infragistics. Behavior like this is to be expected because you cannot update a UI control on a background thread unless you are thread marshalling.
I recommend reading this article for more details about proper thread-safe calls to windows forms controls:https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls