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.<SPAN>  </SPAN>I have bound a BindingList to a SheetView; Can I autosort rows based on column data?<SPAN>  </SPAN>The following is typical row data and the order I would like to sort.  <SPAN>The list is dynamically updated and appended.</SPAN>



    <o:p> </o:p>

    1<SUP>st</SUP><SPAN>        </SPAN><SPAN>            </SPAN>2<SUP>nd</SUP><SPAN>                   </SPAN>3<SUP>rd</SUP><SPAN>        </SPAN>

    Track Name <SPAN>   </SPAN>Station<SPAN>            </SPAN>Offset

    Inbound <SPAN>          </SPAN>10000<SPAN>              </SPAN>100

    Inbound<SPAN>           </SPAN>10000<SPAN>  </SPAN><SPAN>            </SPAN>250<SPAN>      </SPAN>

    Inbound<SPAN>           </SPAN>10500<SPAN>              </SPAN>150

    Outbound<SPAN>        </SPAN>10000<SPAN>              </SPAN>100

    <o:p> </o:p>

    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 = <SPAN class=kwd>new</SPAN> FarPoint.Win.Spread.SortInfo[] {<SPAN class=kwd>new</SPAN> FarPoint.Win.Spread.SortInfo(0,<SPAN class=kwd>true</SPAN>),<SPAN class=kwd>new</SPAN> FarPoint.Win.Spread.SortInfo(1,<SPAN class=kwd>true</SPAN>),<SPAN class=kwd>new</SPAN> FarPoint.Win.Spread.SortInfo(2,<SPAN class=kwd>true</SPAN>)};
    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.<SPAN>  </SPAN>Sorry for wasting your time.

    <o:p> </o:p>






    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