while sorting do not want to move the entire row

Posted by: red60man on 8 September 2017, 2:56 pm EST

  • Posted 8 September 2017, 2:56 pm EST

    hi,

     I am sorting single rows and multiple columns like this

      private void sort_Click(object sender, EventArgs e)
            {

                FarPoint.Win.Spread.Model.CellRange cr = fpSpread1.ActiveSheet.GetSelection(0);

                FarPoint.Win.Spread.SortInfo[] sorter = new FarPoint.Win.Spread.SortInfo[3];
                sorter[0] = new FarPoint.Win.Spread.SortInfo(cr.Row, true, System.Collections.Comparer.Default);
                sorter[1] = new FarPoint.Win.Spread.SortInfo(cr.Row + 1, true, System.Collections.Comparer.Default);
                sorter[2] = new FarPoint.Win.Spread.SortInfo(cr.Row + 2, true, System.Collections.Comparer.Default);
                fpSpread1.ActiveSheet.SortColumns(cr.Column, cr.ColumnCount, sorter);
            }

    private void sortDesc_Click(object sender, EventArgs e)
            {
                FarPoint.Win.Spread.Model.CellRange cr = fpSpread1.ActiveSheet.GetSelection(0);

                FarPoint.Win.Spread.SortInfo[] sorter = new FarPoint.Win.Spread.SortInfo[1];

                    sorter[0] = new FarPoint.Win.Spread.SortInfo(cr.Column, false , System.Collections.Comparer.Default);
                    fpSpread1.ActiveSheet.SortRows(cr.Row, cr.RowCount, sorter);
                }

     

    both methods move the entire row associated with them...i dont want that to happen .....i want to move only the selected rows cells to move.

    row1  121 34 56 23 5

    row2  big  tt    uu yy  io

    i do not want to move the row2 i want to move only the selected the row1 values

     

    thanks

    Red

     

  • Replied 8 September 2017, 2:56 pm EST

    Red,

    The SortRows and SortColumns method move entire rows and columns. To move less that an entire rows and columns, use the SortRange method.

    fpSpread1.ActiveSheets.SortRange(row, column, rowCount, columnCount, byRows, sortInfo);

    Only cells in the range (i.e. row, column, rowCount, columnCount) are moved. The byRows parameter determines if cells in the range are sorted by rows or by columns.

  • Replied 8 September 2017, 2:56 pm EST

    thank you bobbyo

     

Need extra support?

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

Learn More

Forum Channels