Error Setting DataSource - Invalid column index: 0 (must be between -1 and -1)

Posted by: andrew_xiaofeng on 8 September 2017, 3:19 pm EST

  • Posted 8 September 2017, 3:19 pm EST

    We use Farpoint spread (version 7.35.20132.1) for our windows application.

    it throws an exception from the last line of code when executing the following code.

    fpSpread1.DataSource = null;
    fpSpread1.DataMember = null;

    if (fpSpread1.ActiveSheet.RowCount > 0)
    {
    fpSpread1.ShowCell(0, 0, 0, 0, FarPoint.Win.Spread.VerticalPosition.Top, FarPoint.Win.Spread.HorizontalPosition.Left);
    }

    fpSpread1_Sheet1.Columns.Clear();
    fpSpread1.DataSource = dataSource;

    the weird thing is the issue does not always happen, even if we use the same case. so it is sporadic thing. it is difficult to reproduce it.

    Few of our users started getting following error from DataSource method intermittently.

    Inner Exception
    —————

    Type : System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Message :
    Underlying Exception: Invalid column index: 0 (must be between -1 and -1)

    Exception 1: Invalid column index: 0 (must be between -1 and -1)
    at FarPoint.Win.Spread.Model.DefaultSheetStyleModel.GetCompositeInfo(Int32 row, Int32 column, Int32 altIndex, StyleInfo destInfo)
    at FarPoint.Win.Spread.SheetView.a(Int32 A_0, Int32 A_1, StyleInfo A_2, Boolean A_3)
    at FarPoint.Win.Spread.SpreadView.SetAutoImeMode()
    at FarPoint.Win.Spread.SpreadView.a(Object A_0, SheetViewPropertyChangeEventArgs A_1)
    at FarPoint.Win.Spread.SheetViewPropertyChangeEventHandler.Invoke(Object sender, SheetViewPropertyChangeEventArgs e)
    at FarPoint.Win.Spread.SheetView.FirePropertyChanged(String propertyName)
    at FarPoint.Win.Spread.SheetView.b(Int32 A_0, Int32 A_1, Boolean A_2, Boolean A_3)
    at FarPoint.Win.Spread.SheetView.SetActiveCell(Int32 row, Int32 column, Boolean clearSelection)
    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.DefaultSheetDataModel.OnChanged(SheetDataModelEventArgs e)
    at FarPoint.Win.Spread.Model.DefaultSheetDataModel.FireChanged(Int32 row, Int32 column, Int32 rowCount, Int32 columnCount, SheetDataModelEventType type)
    at FarPoint.Win.Spread.Model.DefaultSheetDataModel.j(Int32 A_0, Int32 A_1)
    at FarPoint.Win.Spread.Model.DefaultSheetDataModel.set_DataSource(Object value)
    at FarPoint.Win.Spread.SheetView.set_DataSource(Object value)
    at FarPoint.Win.Spread.FpSpread.set_DataSource(Object value)

    So far we have not been able to replicate this issue on any Developer machines.

    Can you please help us understand what could be the reasons of this failure ? Under what circumstances Farpoint code can fail with this exception ? or any workaround?

    Thanks
  • Replied 8 September 2017, 3:19 pm EST

    more information:
    in the code, the object dataSource is a System.Data.DataTable object or system.Data.DataView.
  • Marked as Answer

    Replied 8 September 2017, 3:19 pm EST

    Hello,

    We are sorry but we were unable to replicate the issue mentioned by you and you too have mentioned that the issue is sporadic. Hence, we cannot comment on the cause of the issue.

    However, a suggestion for you is to try calling the ResetFilter method before resetting the DataSource.

    Also, please note that the issue was tested with the latest build of Spread. Request you to try the workaround and share your observations with us.

    Regards,
    Mohita
Need extra support?

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

Learn More

Forum Channels