Crashes while searching data beyond the scrollable area.

The following is the key response code.

Image_8435_1732679225373

after click test1, and search for 200,

Image_9250_1732679296405

System.ArgumentOutOfRangeException: 200 out of range 0 to 102

参数名: index

   在 Syncfusion.UI.Xaml.Grid.ScrollAxis.DistanceRangeCounterCollection.CheckRange(String paramName, Int32 from, Int32 to, Int32 actualValue)

   在 Syncfusion.UI.Xaml.Grid.ScrollAxis.DistanceRangeCounterCollection._GetCumulatedDistanceAt(Int32 index)

   在 Syncfusion.UI.Xaml.Grid.ScrollAxis.DistanceRangeCounterCollection.GetCumulatedDistanceAt(Int32 index)

   在 Syncfusion.UI.Xaml.Grid.ScrollAxis.PixelScrollAxis.ScrollInView(Int32 lineIndex, Double lineSize)

   在 Syncfusion.UI.Xaml.Grid.ScrollAxis.ScrollAxisBase.ScrollInView(Int32 lineIndex)

   在 Syncfusion.UI.Xaml.CellGrid.GridCurrentCell.ScrollInView(RowColumnIndex rowColumnIndex)

   在 Syncfusion.UI.Xaml.CellGrid.GridCurrentCell.SelectCurrentCell(Int32 row, Int32 col, GridColumn gridColumn)

   在 Syncfusion.UI.Xaml.CellGrid.GridCurrentCell.MoveCurrentCell(RowColumnIndex rowColIndex, GridColumn gridColumn, Boolean forceMove, ActivationTrigger activationTrigger)

   在 Syncfusion.UI.Xaml.CellGrid.SelectionController.AddSelection(GridRangeInfo range)

   在 Syncfusion.UI.Xaml.Spreadsheet.Commands.FindAndReplaceWindow.MoveCurrentCell(IRange found_Range)

   在 Syncfusion.UI.Xaml.Spreadsheet.Commands.FindAndReplaceWindow.FindNextButton_Click(Object sender, RoutedEventArgs e)

   在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

   在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

   在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)



3 Replies

MS Malini Selvarasu Syncfusion Team November 27, 2024 12:33 PM UTC

Hi crosslife,

Thank you for providing detailed information regarding the issue you are experiencing. Based on the details shared, we understand that you are encountering an issue when searching for text in a spreadsheet. From your code snippet, it appears that you updated the row count at runtime but only updated the `ActiveGrid.RowCount`. As a result, the `DefaultRowCount` was not updated, leading to an `IndexOutOfRangeException`.
To resolve this issue, you need to update both the `DefaultRowCount` and `Spreadsheet.ActiveGrid.RowCount`. This will ensure that the exception is not thrown, and the text search will function correctly. Please refer to the code snippet below and let us know if it resolves your issue.
Code Snippet:
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
    spreadsheet.DefaultRowCount = 1000;
     spreadsheet.ActiveGrid.RowCount = 1000;
     var worksheet = spreadsheet.ActiveSheet;
     for(int i = 1; i < 1000; i++)
     {
         var range = worksheet.Range[i, 1];
         spreadsheet.ActiveGrid.SetCellValue(range,cellValue:i.ToString());
     }

}
Thank you for your cooperation and understanding.

Regards,
Malini Selvarasu


CR crosslife November 28, 2024 06:29 AM UTC


After implementing DefaultRowCount, the scroll region works properly, but crashes still occur when repeatedly modifying row counts and searching.


see the code below and the attachment.


Image_8186_1732775285273


Attachment: 20241128142833_WindowShot_6648ad0.zip


MS Malini Selvarasu Syncfusion Team November 29, 2024 01:16 PM UTC

Hi crosslife,

Thank you for providing the details. Based on the information shared, we understand that you encountered an exception while resetting the DefaultRowCount and ActiveGridRowCount during a record search. After reviewing the provided code snippet, we observed that within the ButtonBase_OnClick2 event, the DefaultRowCount and ActiveGridRowCount were set to 100. However, the exception occurred because a search was attempted beyond the available rows.
To resolve this, you do not need to update the DefaultRowCount and ActiveGridRowCount each time the button is clicked. Instead, focus on updating the data itself without modifying the row count every time. It is important to maintain the DefaultRowCount as it is. When the DefaultRowCount is set to 100, the available data will be checked within that range. Thank you for your understanding.
Regards,
Malini Selvarasu

Loader.
Up arrow icon