示例#1
0
 /// <summary>
 /// FarPoint区域排序
 /// </summary>
 /// <param name="fpread">farpoint</param>
 /// <param name="index">列序号集合</param>
 /// <param name="rowDetailStartIndex">开始行号</param>
 /// <param name="rowsCount">排序行数</param>
 /// <param name="columnsCount">排序列数</param>
 public static void farpointSortRange(FarPoint.Win.Spread.FpSpread fpread, int [] index, int rowDetailStartIndex, int rowsCount, int columnsCount)
 {
     fpread.ActiveSheet.Protect = false;
     FarPoint.Win.Spread.SortInfo[] sorter = new FarPoint.Win.Spread.SortInfo[index.Length];
     for (int i = 0; i < index.Length; i++)
     {
         sorter[i] = new FarPoint.Win.Spread.SortInfo(index[i], false, System.Collections.Comparer.Default);
     }
     fpread.ActiveSheet.SortRange(rowDetailStartIndex, index[0], rowDetailStartIndex + rowsCount, columnsCount, true, sorter);
 }
 protected virtual void OnSort()
 {
     //点的是标题行
     if (this.SvMain.ActiveRowIndex == this.dataBeginRowIndex - 1)
     {
         //点的是标题列
         if (this.SvMain.ActiveColumnIndex <= this.dataBeginColumnIndex + this.dataDisplayColumns.Length - 1 && this.SvMain.ActiveColumnIndex >= this.dataBeginColumnIndex)
         {
             //新建排序条件
             FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[1];
             //遍历标题列取原排序条件
             for (int i = dataBeginColumnIndex; i < this.dataDisplayColumns.Length; i++)
             {
                 bool ascending = true;
                 if (i == this.SvMain.ActiveColumnIndex)
                 {
                     //没有“↑”号就是升序
                     if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("▽") < 0)
                     {
                         //
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("△", "");
                         ascending = false;
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text + "▽";
                     }
                     else
                     {
                         //
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("▽", "");
                         ascending = true;
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text + "△";
                     }
                     //生成排序信息
                     sort[0] = new FarPoint.Win.Spread.SortInfo(i, ascending, System.Collections.Comparer.Default);
                 }
                 else
                 {
                     //没有“↑”号就是升序
                     if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("▽") < 0)
                     {
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("△", "");
                         //ascending = false;
                         //SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "△";
                     }
                     else
                     {
                         SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("▽", "");
                         //ascending = true;
                         //SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "▽";
                     }
                 }
                 //生成排序信息
                 //sort[i] = new FarPoint.Win.Spread.SortInfo(i, ascending, System.Collections.Comparer.Default);
             }
             ////新建排序条件
             //FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[this.dataDisplayColumns.Length];
             ////遍历标题列取原排序条件
             //for (int i = 0; i < this.dataDisplayColumns.Length; i++)
             //{
             //    bool ascending = true;
             //    if (i == this.SvMain.ActiveColumnIndex )
             //    {
             //        //没有“↑”号就是升序
             //        if (SvMain.Cells[this.dataBeginRowIndex, i].Text.IndexOf("▽") < 0)
             //        {
             //            //
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("△", "");
             //            ascending = false;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "▽";
             //        }
             //        else
             //        {
             //            //
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("▽", "");
             //            ascending = true;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "△";
             //        }
             //    }
             //    else
             //    {
             //        //没有“↑”号就是升序
             //        if (SvMain.Cells[this.dataBeginRowIndex, i].Text.IndexOf("▽") <0)
             //        {
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("△", "");
             //            ascending = false;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "△";
             //        }
             //        else
             //        {
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text.Replace("▽", "");
             //            ascending = true;
             //            SvMain.Cells[this.dataBeginRowIndex, i].Text = SvMain.Cells[this.dataBeginRowIndex, i].Text + "▽";
             //        }
             //    }
             //    //生成排序信息
             //    sort[i] = new FarPoint.Win.Spread.SortInfo(i, ascending,System.Collections.Comparer.Default );
             //}
             SvMain.SortRange(this.dataBeginRowIndex, this.dataBeginColumnIndex, this.dataRowCount, this.dataDisplayColumns.Length, true, sort);
         }
     }
 }