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
365
Exception: System.ArgumentOutOfRangeException on
posted

We recently upgraded from 7.3 to 11.2 and randomly get exceptions - one of them occured on the following line as indicated by FAILS ON THIS LINE below.

This grid method contains DataTable search results for existing values entered on a form - if found, it is supposed to move the matching rows to the top of the grid and changes their appearance.
I was wondering - we do not define Infragistics.Win.UltraWinGrid.UltraGridOverride.FixedRowStyle within our code - does it need to be? The rows have always been highlighted on the top of the grid.

Any ideas how to fix this - or safe way to block it?
I found references to using BeginInvoke(new FixedRowDelegate(createFixedRow), e.Row), but this is not a Summary row and this is not a threaded app - and multiple rows could potentially become fixed/highlighted.

Thanks,
Todd

Code:

private void FixCurrentRows() {

try {

if (this.ResultsUltraGrid.Rows != null
&& (m_CurrentId != Guid.Empty || m_CurrentServiceRequestId != Guid.Empty))
{

foreach (UltraGridRow row in this.ResultsUltraGrid.Rows) {
// Fix the Current matching row to the top of the grid when Searching for an Existing individual

if (this.ResultsUltraGrid.Text == "Potential Duplicate Requests"
&& m_CurrentServiceRequestId != Guid.Empty
&& row.Cells.Exists(
"ServiceRequestId")
&& (
Guid)row.Cells["ServiceRequestId"].Value ==  m_CurrentServiceRequestId)
{

row.Fixed = true; // FAILS ON THIS LINE

row.Appearance.BackColor =

 

Color.Yellow;
row.Appearance.BackColor2 =
Color.Goldenrod;
row.Appearance.BackGradientStyle =
GradientStyle.GlassBottom50Bright;
break;
// Exit the loop since we found the current service request

}
else

if(m_CurrentId != Guid.Empty
&& row.Cells.Exists(
"UserId")
&& (
Guid)row.Cells["UserId"].Value == m_CurrentId)
{

row.Fixed = true;

row.Appearance.BackColor = Color.Yellow;
row.Appearance.BackColor2 =
Color.Goldenrod;
row.Appearance.BackGradientStyle =
GradientStyle.GlassBottom50Bright;

}

}

}

}
catch (Exception ex) {
Error.LogException(ex);
}

} 

Exception information:

Additional Information:
Exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
   at Infragistics.Shared.SparseArray.Insert(Int32 index, Object item)
   at Infragistics.Win.UltraWinGrid.RowsCollection.Move(UltraGridRow row, Int32 newIndex, Boolean forceDirtyPrimaryMetrics)
   at Infragistics.Win.UltraWinGrid.RowsCollection.MoveFixedRowsToProperLocation()
   at Infragistics.Win.UltraWinGrid.FixedRowsCollection.VerifyFixedRows(Boolean verifyScrollCount)
   at Infragistics.Win.UltraWinGrid.FixedRowsCollection.IndexOf(Object obj)
   at Infragistics.Shared.DisposableObjectCollectionBase.Contains(Object obj)
   at Infragistics.Win.UltraWinGrid.UltraGridRow.get_Fixed()
   at Infragistics.Win.UltraWinGrid.UltraGridRow.set_Fixed(Boolean value)
   at UI.WindowsForms.GeneralForms.SearchForm.FixCurrentRows()
  in d:\Sources\UI.WindowsForms\GeneralForms\SearchForm.cs:line 290

Parents
  • 469350
    Offline posted

    Hi,

    It's hard to say for sure without seeing a sample and duplicating the problem. But based on the exception, I have a couple of guesses.

    1) Is your project using multiple threads? It looks like the rows collection in the grid is getting out of synch, which can happen with threading.

    2) It's generally a bad idea to move, delete, or add rows to a collection while you are enumerating that collection (like you are doing here with your 'foreach'. You are not adding or deleting anything, but fixing the row is equivalent to moving it to a new location in the collection.

    So what I would do is change the your 'foreach' statement to use an Array of the rows and see if that helps.This works because while you might be changing the order of the rows in the Rows collection, the array will not be affected.

    Of course, that doesn't explain why it worked in the old version, but maybe something changed internally in the grid regarding when it updates the order of the Rows.

    Todd N said:
    I was wondering - we do not define Infragistics.Win.UltraWinGrid.UltraGridOverride.FixedRowStyle within our code - does it need to be?

    No. Top is the default. You only need to set this if you want the rows fixed at the bottom.

Reply Children