delphi – 反转ClientDataSet索引的顺序

前端之家收集整理的这篇文章主要介绍了delphi – 反转ClientDataSet索引的顺序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要反转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属性即可来回切换.

原文链接:https://www.f2er.com/delphi/239250.html

猜你在找的Delphi相关文章