Does SortRange update tags associated with rows in sheet?

Posted by: ashish01 on 8 September 2017, 1:14 pm EST

  • Posted 8 September 2017, 1:14 pm EST


    In our application we use Tag attribute of Row and Column objects extensively. Now as automatix sorting only sorts selection model and not the underlyining data model, I captured AutoSortingColumn event and here is the code snippet 

            private void mainSpread_AutoSortingColumn(object sender, AutoSortingColumnEventArgs e)
    FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[1];
    sort[0] = new FarPoint.Win.Spread.SortInfo(0, true, System.Collections.Comparer.Default);
    mainSheet.SortRows(0, true, true);
    //mainSheet.SortRange(0, e.Column, mainSheet.RowCount, mainSheet.ColumnCount, true, sort);
    //e.Cancel = true;


     But even after doing this, I get reference to old (unsorted) rows when using Tags (unique for each row).

    Can you please tell me how to do this correctly?



  • Replied 8 September 2017, 1:14 pm EST

    Ashis -

    When you use the SortRows method the tags will move with the sorted rows and columns.  So if row 4 had a tag of "Row4" and its new position is at row 15 it will still have a tag of "Row4".  This is the intended behavior.  If you use SortRange the tags will not be sorted.
  • Replied 8 September 2017, 1:14 pm EST


    My requirment is that once sorting is initiated by the user the data model is in sync with the data displayed on the screen.

    Ex. Row 4 had tag "Row4" and index 3.  So ActiveSheet.Rows["Row4"].index returns 3.

    Now after sorting say its index was modified to 13, so now ActiveSheet.Rows["Row4"].index should return 13.


    Can this be done?



  • Replied 8 September 2017, 1:14 pm EST


    WHen you call the SortRows method in Spread, the View of Spread is what is sorted. The underlying DataModel is not sorted. This is to make the Spread perform more effeciently. Because of this, you will now have two coordinate systems; the DataModel and the Viewport. There are two methods (GetViewRowFromModelRow and GetModelRowFromViewRow) that you can use to translate coordinates from one to the other.

  • Replied 8 September 2017, 1:14 pm EST

    Thanks a lot scotts








Need extra support?

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

Learn More

Forum Channels