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
I do have the same issue with 2011 volume 2... The same code was working fine in the previous version (2009 vol 2) but now I had to include a new line of code before updating the Datasource (datatable) to avoid this issue...
if (_grid.ActiveCell != null) _grid.ActiveCell.Activated = false;
Hi,
I tried this out and I cannot reproduce the exception. I have attached my sample project here so you can see if I am doing something differently than you are.
Basically, I bind the grid to a table with a single row and fix that row.
Then I bind the grid to a new DataTable with 4 rows and fix all four of them.
It works just fine for me.
Found it... caused when reassigning a new datasource does not reinitialize the grids internal FixedRow table.
The problem is that despite a new datasource being assigned to the grid - it retains its prior FixedRow table, causing the index to exceed the row count of the data.
With our situation, onload it sets one row to the FixedRow table, then the a form selecton causes a reload and assigns a new datasource and tries to set all 4 rows of the new datasource as Fixed, resulting in trying to add a 5th row to the Fixed table and throws the exception.
I would suggest you bug this and add an DataSource changed event to delete prior content from the grid.FixedRow table.
Well, tried the grid.Update(); when setting Fixed on one row - it is ok. When it calls to set on all 4 rows in the table, it fails immediatey after the last row - showing a red X on the grid and crashing the application.
I had tried .refresh, .update, a whole bunch of them, manually called after each, starting over on row 0 assuming the rows had moved, checking if fixed=true and starting over each time one was changed - no difference.
I will try pulling this into a small app and see if I can reproduce this.
Actually... another possibility just occurred to me.
I assume that the Exception never occurs the first time you set Fixed to true on the row, it probably only occurs on the second or subsequent row. Is that correct?
If so, then perhaps the issue is that the grid hasn't yet updated the index of that row when you are fixing the next row.
If that's true, then you might be able to get around it by forcing the grid to update the indices after each row is fixed. So keep the BeginInvoke and immediately after you set the the Fixed property to true, try calling:
grid.Update();
That will force the grid to paint, which should verify all the row indices.