Auto Sorting via Multiple Columns and Merging

Posted by: aron_31 on 8 September 2017, 1:04 pm EST

  • Posted 8 September 2017, 1:04 pm EST

    I have a question.  I have bound a BindingList to a SheetView; Can I autosort rows based on column data?  The following is typical row data and the order I would like to sort.  The list is dynamically updated and appended.




    1st                    2nd                   3rd       

    Track Name    Station            Offset

    Inbound           10000              100

    Inbound           10000              250     

    Inbound           10500              150

    Outbound        10000              100


    Finally, can I auto merge the cell with the same values?

    I am using WinSpread v2.5 and VC#.



  • Replied 8 September 2017, 1:04 pm EST


    Here is code to perform the 3 key sort and to merge like data in all the columns.

    	FarPoint.Win.Spread.SortInfo[] si = new FarPoint.Win.Spread.SortInfo[] {new FarPoint.Win.Spread.SortInfo(0,true),new FarPoint.Win.Spread.SortInfo(1,true),new FarPoint.Win.Spread.SortInfo(2,true)};
    fpSpread1.Sheets[0].SortRows(0, fpSpread1.Sheets[0].RowCount, si);
    fpSpread1.Sheets[0].Columns.Default.MergePolicy = MergePolicy.Always ;
  • Replied 8 September 2017, 1:04 pm EST

    So everytime I add a record I have to raise an event and resort; I thought so.  Sorry for wasting your time.







    I implemented the code and it works fine the first time I sort the records, but if I add a record to my BindingList after the sort I get the following error.  Why? 


    System.IndexOutOfRangeException was unhandled
      Message="Invalid index specified: 5\r\n(current length is 5)"

  • Replied 8 September 2017, 1:04 pm EST


    I believe this was a bug in a previous release. Make sure you have the latest release. If you do, could you post a small zipped project reproducing this behavior for us to debug?

Need extra support?

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

Learn More

Forum Channels