IndexName (C++)
Description
This example uses the IndexName property to sort the records in a client dataset on the Field2 field.
Code
void __fastcall TForm1::Button3Click(TObject *Sender)
{
// If Active is True, Update removes Fields added in FormCreate
// and adds the DEFAULT_ORDER and CHANGEINDEX Fields.
CDS2->Active = False;
// Get the current available indices.
CDS2->IndexDefs->Update();
// Find a field named "Field2".
for (int I = 0; I < CDS2->IndexDefs->Count; I++)
if (CDS2->IndexDefs->Items[I]->Fields == "Field2")
{
// Set that index as the current index for the dataset. }
CDS2->IndexName = CDS2->IndexDefs->Items[I]->Name;
}
CDS2->Active = True;
}
Uses
- Datasnap.DBClient.TCustomClientDataSet.IndexDefs ( fr | de | ja )
- Datasnap.DBClient.TCustomClientDataSet.IndexName ( fr | de | ja )
- Data.DB.TIndexDefs.Update ( fr | de | ja )
- System.Classes.TCollection.Count ( fr | de | ja )
- Data.DB.TIndexDefs.Items ( fr | de | ja )
- Data.DB.TIndexDef.Fields ( fr | de | ja )
- Data.DB.TNamedItem.Name ( fr | de | ja )