加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 反转ClientDataSet索引的顺序

发布时间:2020-12-15 04:07:55 所属栏目:大数据 来源:网络整理
导读:我想要反转TClientDataSet中索引的顺序,下面的代码看起来应该做的伎俩但什么都不做.有没有一种很好的方法来扭转索引的顺序? procedure TForm8.Button1Click(Sender: TObject);var index: TIndexDef;begin index := ClientDataSet1.IndexDefs.Find('LengthIn
我想要反转TClientDataSet中索引的顺序,下面的代码看起来应该做的伎俩但什么都不做.有没有一种很好的方法来扭转索引的顺序?
procedure TForm8.Button1Click(Sender: TObject);
var
  index: TIndexDef;
begin
  index := ClientDataSet1.IndexDefs.Find('LengthIndex');
  if ixDescending in index.Options then
    index.Options := index.Options - [ixDescending]
  else
    index.Options := index.Options + [ixDescending];
end;

解决方法

创建索引时使用TIndexDef.Options.它们不能用于尝试影响现有索引.见 documentation(强调我的):

When creating a new index,use Options to specify the attributes of the index. Options can contain zero or more of the TIndexOption constants ixPrimary,ixUnique,ixDescending,ixCaseInsensitive,and ixExpression.

When inspecting the definitions of existing indexes,read Options to determine the option(s) used to create the index.

您需要使用ixDescending值集创建单独的索引.然后,您只需更改IndexName属性即可来回切换.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读