Exception occurs when rows are auto sorted

Posted by: rinmei11 on 8 September 2017, 2:12 pm EST

  • Posted 8 September 2017, 2:12 pm EST


    I have trouble with auto sort.

    System.ArgumentOutOfRangeException occurs when operating along following procedure.

    [Spread for Windows Forms 2 version]

    1. Click column header and spread is sorted. (Auto sorted)

    2. Set Spread.SheetView.RowCount = 1

    3. System.ArgumentOutOfRangeException occurs

    System.ArgumentOutOfRangeException: Invalid row index specified (must be between 0 and 0).
    Parameter name: row
    Actual value was 1.
       at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
       at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    Is this famous problem?


    By the way I found thread about trouble on auto sort in the forum.



    I inserted "Spread.SheetView.AutoSortColumn(0)" before "Spread.SheetView.RowCount = 1" to reset column used for sorting.

    After that, the problem stops occurting.

    Does this a right coping technique?


     Please give me advice.


  • Replied 8 September 2017, 2:12 pm EST


    What problem are you experiencing with AutoSortColumns, in case you will set the Rowcount=1 before applying AutoSortColumn you will get the exception as it will not be able to fine the RowIndex e.g.

            FpSpread1.Sheets(0).RowCount = 1
            FpSpread1.Sheets(0).Cells(0, 0).Value = 123
            FpSpread1.Sheets(0).Cells(1, 0).Value = 12
            FpSpread1.Sheets(0).Cells(2, 0).Value = 2
            FpSpread1.Sheets(0).Cells(3, 0).Value = 14

    The above code will throw you the same exception.  In case you are facing the same problem as described in bug# 15021, could you please upgrade to the latest available version of SPread (if not done already). If you are facing a different problem, then please let us know.

  • Replied 8 September 2017, 2:12 pm EST

    Thanks for reply.

    My description for procedure had some mistaken and I corrected them.
    I think my problem is a little different from procedure you wrote.
    "RowCount = 1" is executed after auto sorting.

    My trouble procedure
    Previous state:
        - Window which has spread sheet (column count is 16) and radio button is displayed
        - Data for spread sheet is collected by accessing RDB.

    1. Click column header for specified column and spread is sorted. (Auto sorted)
    2. Click radio button. Following processing is executed for spread sheet.
        Spread.FpSpread.ActiveSheet.RowCount = 1

    3. System.ArgumentOutOfRangeException occurs

    Have any trouble been reported on above operation?

    BTW I read description for bug# 15021, but I think my problem is different from that, because I don't remove column.

  • Replied 8 September 2017, 2:12 pm EST



    With the code you have provided, this seems to be the expected behavior.

    The reason being that you are calling SuspendLayout however not calling the ResumeLayout.

    Please see the modified code:


            FpSpread1.ActiveSheet.RowCount = 1


  • Replied 8 September 2017, 2:12 pm EST

    Hello, Amit

    Thank you for your reply.

    I wrote the code until an exception occurs.
    Actually my code has FpSpread1.ResumeLayout() in the last part, but exception occurs before that.
    I'm developing application on visual studio 2003 and debugged the code step by step in debug mode, the result shows that the exception occurs exactly at "RowCount = 1".

    Don't you know the case an exception occurs when value is set to FpSpread1.ActiveSheet.RowCount?

  • Replied 8 September 2017, 2:12 pm EST

    If that is the case, then please attach a sample application in which this issue is getting replicated as I am seeing different results here.

  • Replied 8 September 2017, 2:12 pm EST

    I'm sorry to late that I could not reply sooner.

    I tried to make a sample application which recreates the problem for a week, but I can't yet.

    In parallel I also checked values set to spread's properties using my problematic application, I found that after executing "FpSpread1.ActiveSheet.RowCount = 1", values for NonEmptyColumnCount and NonEmptyRowCount are also updated to "0".
    I'm wondering if this behavior isn't foreseen and it has something to do with my problem.

    I found bug report [22871] witch is related to behavior of NonEmptyColumnCount.
    But there is a little information about the fixed problem.
    I want to know the detail of it.





  • Replied 8 September 2017, 2:12 pm EST



    It could be a possibility that the Bug Number you have mentioned might be related to your application as well. This Bug has already been fixed in the Versions 4.0.2009.2005 and 4.0.3509.2008 which have been released on 12/22/2008.

    Can you please update the machine with any of the required versions and let us know your observations.

  • Replied 8 September 2017, 2:12 pm EST

    Dear Amit.
    Thank you for your reply.

    I want to update spread to latest version and check if my problem doesn't occur, but it is difficult because it is released that prereq spread version for building our application (product) is "Spread for Windows Forms 2.0".
    Mean while, bug report [22871] is fixed on "Spread for Windows Forms 4.0".

    What I can do is to make sure whether there is possibility the problem reported on [22871] occurs in my trouble and whether this bug occurs on "Spread for Windows Forms 2.0" in the same way.
    So I want to know the detail of the [22871].
    And if my trouble is related with bug report [22871], I want to know work around for it.

  • Replied 8 September 2017, 2:12 pm EST



    If possible, can you please attach a running sample application so that I can confirm whether this issue is exactly same as Bug Number 22871.

    Alternatively, you may try installing a trail version of Spread for Windows Forms 4.0 to check if the issue is indeed resolved or not.

    Unfortunately, we will not be making any further bug fixes in Spread for Windows Forms 2.0.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels