Invalid Index Specified Error

Posted by: dotnetuser on 8 September 2017, 12:40 pm EST

  • Posted 8 September 2017, 12:40 pm EST

    <FONT color=#a52a2a>Hi,</FONT>

    <FONT color=#a52a2a>Using Spread .Net 2.05.2008-2005. The spread is being loaded and we're sorting ascending the first column and adding subtotals rows to the spread; also calculating some of the columns. </FONT>

    <FONT color=#a52a2a>But there is an option to display this spread without sorting neither subtotaling. If checked we're clearing the spread and re-populating it. </FONT><FONT color=#a52a2a>But as soon as we set the RowCount = 0 the following error is being displayed:</FONT>

    System.IndexOutOfRangeException occurred
      Message="Invalid index specified: 15
    (current length is 15)"
           at b0.a(Int32 A_0, Int32 A_1)
           at FarPoint.Win.Spread.SheetView.OnRemoveRows(Int32 row, Int32 count)
           at FarPoint.Win.Spread.SheetView.OnDataModelChanged(Object sender, SheetDataModelEventArgs e)
           at FarPoint.Win.Spread.Model.SheetDataModelEventHandler.Invoke(Object sender, SheetDataModelEventArgs e)
           at FarPoint.Win.Spread.Model.BaseSheetDataModel.OnChanged(SheetDataModelEventArgs e)
           at FarPoint.Win.Spread.Model.BaseSheetDataModel.FireChanged(Int32 row, Int32 column, Int32 rowCount, Int32 columnCount, SheetDataModelEventType type)
           at FarPoint.Win.Spread.Model.DefaultSheetDataModel.set_RowCount(Int32 value)
           at FarPoint.Win.Spread.SheetView.set_RowCount(Int32 value)

    <FONT color=#a52a2a>Tried to reproduce this in a test project loading a spread with a few rows sorting then setting the rowcount to 0 but couldn't reproduce it.</FONT>

    <FONT color=#a52a2a>We're not using databinding the spread is being loaded manually. </FONT>

    <FONT color=#a52a2a>Any ideas what could be the problem? Heard before about it in this release?</FONT>

    <FONT color=#a52a2a>Thanks</FONT>


  • Replied 8 September 2017, 12:40 pm EST

    If memory serves me correctly there was a bug in one of the earlier versions of 2.5 when setting the row count = 0.  I would suggest getting the latest maintenance release.  If that doesn't solve your problem could you post a small project reproducing the issue.
  • Replied 8 September 2017, 12:40 pm EST

    <FONT color=#a52a2a size=2>Downloaded Spread release 2.05 (2011-2005) and it didn't help much.</FONT>

    <FONT color=#a52a2a size=2>Unfortunately I can't reproduce this error in a simple/small test project and I already spent to much time on this.</FONT>

    <FONT color=#a52a2a size=2>In order to make it work we implemented a work around consisting of:</FONT>

    <FONT color=#0000ff size=2>private void PopulateSpread</FONT>

    <FONT color=#0000ff size=2>{</FONT>

    <FONT color=#0000ff size=2>   Try</FONT>

    <FONT color=#0000ff size=2>   {</FONT>

    <FONT color=#0000ff size=2>      spdXYZ.Sheets[0].RowCount = 0;</FONT>

    <FONT color=#0000ff size=2>   }</FONT>

    <FONT color=#0000ff size=2>   catch </FONT>

    <FONT color=#0000ff size=2>   {</FONT>

    <FONT color=#0000ff size=2>           spdXYZ.Reset();</FONT>

    <FONT color=#0000ff size=2>           //Re-add the columns a to spread and re-format them</FONT>

    <FONT color=#0000ff size=2>          spdXYZ.Sheets[0].RowCount = 0;</FONT>

    <FONT color=#0000ff>  <FONT size=2>}</FONT></FONT>

    <FONT color=#0000ff><FONT size=2>   </FONT><FONT size=2> //Continue populating the spread as usual</FONT></FONT>

    <FONT color=#0000ff size=2>}</FONT>

    <FONT color=#a52a2a size=2>The reset is fixing the problem but it's clearing all thge columns, column headers and therefore we have to re-add the columns again.</FONT>

    <FONT color=#a52a2a size=2>It's good to have this issue fixed though!.</FONT>

    <FONT color=#a52a2a size=2>Thanks</FONT>

    <FONT size=2></FONT> 



Need extra support?

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

Learn More

Forum Channels