找回密码
 立即注册

QQ登录

只需一步,快速开始

xue5ya

最新发帖
xue5ya
中级会员   /  发表于:2014-10-17 15:17:00
11#
回复 10楼iceman的帖子

好的,多谢解答。
最近有些忙,过几天有时间做个例子传上来。
回复 使用道具 举报
xue5ya
中级会员   /  发表于:2014-10-17 16:22:00
12#
回复 10楼iceman的帖子

刚刚尝试做了个例子,
虽然可以解决掉升序降序转换的问题,
但是以点击列最优先,然后以从左到右的列依次升序或降序排列的功能没有实现,可是debug下查看sorter的内容,确实是被点击列排在最前面,然后从左到右的列依次放入的sorter。
或许理解错了,sorter内容的顺序并不会影响到排序的优先顺序?
还是说有什么其他的原因。
代码如下,方便参考:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;

  8. namespace WindowsApplication1
  9. {
  10.     public partial class Form1 : Form
  11.     {
  12.         bool isAsc = true;//true:ASC false:DESC
  13.         int clickColIndex = -1;//ColumnIndex has been Clicked

  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.             this.fpspdX.ActiveSheet.RowCount = 10;
  18.             this.fpspdX.ActiveSheet.ColumnCount = 10;
  19.             this.fpspdX.Sheets[0].Columns[0,9].AllowAutoSort = true;
  20.         }

  21.         private void fpspdX_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
  22.         {
  23.             if (e.ColumnHeader == true &amp;&amp; e.Column > -1 &amp;&amp; e.Column < 10)//Column1~Column10
  24.             {
  25.                 if (!e.RowHeader)//Header
  26.                 {
  27.                     int colAct = e.Column;

  28.                     if (clickColIndex == colAct)//
  29.                     {
  30.                         //ASC <=> DESC
  31.                         if (isAsc == true)
  32.                         {
  33.                             isAsc = false;
  34.                         }
  35.                         else
  36.                         {
  37.                             isAsc = true;
  38.                         }

  39.                         clickColIndex = colAct;//to memo
  40.                     }

  41.                     FarPoint.Win.Spread.SortInfo[] sorter = new FarPoint.Win.Spread.SortInfo[10];
  42.                     //First
  43.                     sorter[0] = new FarPoint.Win.Spread.SortInfo(colAct, isAsc, System.Collections.Comparer.Default);
  44.                     //
  45.                     int index = 1;
  46.                     for (int i = 0; i < 10; i++)
  47.                     {
  48.                         if (i == colAct)
  49.                         {
  50.                             continue;
  51.                         }
  52.                         else
  53.                         {
  54.                             sorter[index] = new FarPoint.Win.Spread.SortInfo(i, isAsc, System.Collections.Comparer.Default);
  55.                             index = index + 1;
  56.                         }
  57.                     }

  58.                     fpspdX.ActiveSheet.SortRows(0, fpspdX.ActiveSheet.RowCount, sorter);

  59.                 }//END FOR  if (!e.RowHeader)
  60.             }
  61.         }

  62.     }
  63. }
复制代码
回复 使用道具 举报
xue5ya
中级会员   /  发表于:2014-10-17 16:36:00
13#
截图如下:

Sorter.png
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-10-17 19:02:00
14#
回复 13楼xue5ya的帖子

FarPoint.Win.Spread.SortInfo[]顺序会影响排序顺序。你的问题我已经了解,调试后给你反馈。
回复 使用道具 举报
xue5ya
中级会员   /  发表于:2014-10-30 16:32:00
15#
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-10-31 10:07:00
16#
回复 15楼xue5ya的帖子

抱歉,让您久等了今天会给您进一步反馈。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-11-2 20:01:00
17#
回复 15楼xue5ya的帖子

我使用 12# 的代码,参照 13# 设置,是按照sortinfo[] 顺序进行排序的:

无标题.png

我使用的 Spread 版本是 7.35.20142.0,应该是版本不同引起的,请您下载最新版测试:
http://www.gcpowertools.com.cn/d ... SpreadStudio7v4.zip
回复 使用道具 举报
12
您需要登录后才可以回帖 登录 | 立即注册
返回顶部