client,dataset,index,delphi

Omar 10/12/2016 0

The code below creates a new case-insensitive index at run time 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.

Delphi
 {$IFNDEF UNICODE}
uses SwSystem;
{$ENDIF}
 
procedure TForm1.QuickIndexClick(Sender: TObject);
begin
  if (Edit1.Text <> '') and
     (CDS.Fields.FindField(Edit1.Text) <> nil) then
  begin
    CDS.AddIndex(Edit1.Text   'Index', Edit1.Text, [ixCaseInsensitive],'','',0);
    CDS.IndexName := Edit1.Text   'Index';
  end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
{$IFDEF UNICODE}
  CDS.LoadFromFile(GetCurrentDir   '\CDS.XML');
{$ELSE}
  CDS.LoadFromFile(gsAppPath   'CDS.XML');
{$ENDIF}
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
{$IFDEF UNICODE}
  CDS.SaveToFile(GetCurrentDir   '\CDS.XML', dfXML);
{$ELSE}
  CDS.SaveToFile(gsAppPath   'CDS.XML', dfXML);
{$ENDIF}
end;
 
procedure TForm1.Button3Click(Sender: TObject);
begin
  CDS.CreateDataSet;
end;
 
procedure TForm1.Button5Click(Sender: TObject);
begin
  CDS.Close;
end; 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments