
(*
 Delphi Object and Component Reference
 AddIndex example
The code below creates a new case-insensitive index at runtime and then sorts the client dataset using that index. The user specifies the field on which to sort the client dataset in an edit control. 
*) 
void __fastcall TForm1::QuickIndexClick(TObject *Sender)
{
  if ((!Edit1->Text.IsEmpty()) &&
     ClientDataSet1->Fields->FindField(Edit1->Text))
  {
    TIndexOptions opts;
    opts << ixCaseInsensitive;
    ClientDataSet1->AddIndex(Edit1->Text + "Index", Edit1->Text, opts, "", "",0);
    ClientDataSet1->IndexName = Edit1->Text + "Index";
  }
} 
