Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

Example

This code clears the SortFields properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SortFields.Clear;

This code clears the SortFields properties for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.SortFields.Clear; end;

SortFields CopyFrom method

Declaration

function CopyFrom(Source: TCrpeSortFields): boolean;

Description

The CopyFrom method copies the SortFields property values from another TCrpeSortFields object. It is similar to Delphi's Assign method. It is useful for transferring or temporary storage of values.

Example

The following example copies all the SortFields property values to a temporary TCrpeSortFields object:

var

tempSortFields : TCrpeSortFields; begin

tempSortFields := TCrpeSortFields.Create; tempSortFields.CopyFrom(Crpe1.SortFields); {...later, when finished with the temp object...} tempSortFields.Free;

end;

SortFields Count method

Declaration

function Count: integer;

VCL Reference

618

Description

The Count method can be used to obtain the number of items currently in the SortFields object. It is handy for setting up loops to make similar changes to each item.

Example

The Count method is useful for looping constructions. You would normally want to call Retrieve first:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.SortFields.Retrieve;

for cnt := 0 to (Crpe1.SortFields.Count - 1) do Crpe1.SortFields[cnt].Direction := sdDescending;

end;

SortFields Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SortFields object, and does not need to be called in code.

SortFields Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SortFields object. The "nIndex" parameter represents the number of the item in the SortFields object, which may not be the same as the SortFields Number value.

NOTE: Delete will not remove the SortField from the Report, it will just remove it from the Crystal VCL. Set the DeleteSF property to remove a SortField from the Report.

VCL Reference

619

Example

The Delete method can be used to manually remove an item from the SortFields object:

Crpe1.ReportName := 'C:\Company.rpt'; {Specify SortField Number} Crpe1.SortFields.Add(0); Crpe1.SortFields.Field := '{company.STATE}'; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SortFields.Delete(0);

SortFields Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

NOTE: The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it. The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.

SortFields Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SortFields from the Report and stores them in the SortFields object. If no SortFields were found, the call returns False. Be aware that calling Retrieve will first cause the SortFields object to be cleared, so any current information stored in it will be removed.

NOTE: Since the SortFields object also applies to Subreports, the Retrieve method will obtain the SortFields for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the SortFields information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item. The VCL will store separate SortFields information for each Subreport (see Example).

VCL Reference

620

Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.SortFields.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Subreports.Retrieve;

{Loop through Reports and Retrieve}

for cnt := 0 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.SortFields.Retrieve; end;

{Set Crpe component back to main Report} Crpe1.Subreports[0];

end;

SortFields Send method

Declaration

function Send: boolean;

Description

The Send method sends the SortFields values to the Crystal Reports Print Engine. This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

It is strongly recommended that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine. If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method. This feature is mainly provided for debugging purposes.

Example

In this example, the SortFields settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.SortFields.Send;

VCL Reference

621

Соседние файлы в папке crystal