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

Example

The following code will retrieve all the Parameter fields in a Report, whether they are in a main Report or a Subreport. Note that ParamFields behave slightly differently in this respect than other objects:

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

{Retrieve the ParamFields}

Crpe1.ParamFields.Retrieve;

The next example shows how to retrieve only the Parameter fields that apply to a specific Subreport. This should only be necessary if the Subreport is going to be run as a stand-alone Report, separate from the main Report:

Crpe1.ReportName := 'C:\Company.rpt'; {Retrieve the Subreports items} Crpe1.Subreports.Retrieve;

{Allow Subreports to be run stand-alone} Crpe1.Subreports.SubExecute := True;

{Set the Crpe to point to the 2nd Subreport} Crpe1.Subreports[2];

{Retrieve the ParamFields for the 2nd Subreport} Crpe1.ParamFields.Retrieve;

ParamFields Send method

Declaration

function Send: boolean;

Description

The Send method sends the ParamFields 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 recommend 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 ParamFields settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.ParamFields.Send;

VCL Reference

483

PrintDate Properties

PrintDate Day property

Declaration

property Day: Word;

Description

This property sets the Day portion of the PrintDate. Enter a Day value from 1 to 31. When setting PrintDate, all three properties (Day, Month, Year) must be greater than 0 for the new PrintDate to take effect.

Example

The following sample sets the PrintDate to January 1, 1999:

Crpe1.ReportName := 'MyReport.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1999;

Crpe1.Execute;

PrintDate Month property

Declaration

property Month: Word;

Description

This property sets the Month portion of the PrintDate. Enter a Month value from 1 to 12, where January = 1 and December = 12. When setting PrintDate, all three properties (Day, Month, Year) must be greater than 0 for the new PrintDate to take effect.

Example

The following sample sets the PrintDate to January 1, 1999:

Crpe1.ReportName := 'MyReport.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1999;

Crpe1.Execute;

VCL Reference

484

PrintDate Year property

Declaration

property Year: Word;

Description

This property sets the Year portion of the PrintDate. Enter the Year as a four-digit number. When setting PrintDate, all three properties (Day, Month, Year) must be greater than 0 for the new PrintDate to take effect.

Example

The following sample sets the PrintDate to January 1, 1999:

Crpe1.ReportName := 'MyReport.rpt';

Crpe1.PrintDate.Day := 1;

Crpe1.PrintDate.Month := 1;

Crpe1.PrintDate.Year := 1999;

Crpe1.Execute;

PrintDate Methods

PrintDate Clear method

Declaration

procedure Clear;

Description

This method can be used to set the PrintDate properties to their default values:

Day := 0;

Month := 0;

Year := 0;

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.

Example

This line of code clears the PrintDate properties:

Crpe1.PrintDate.Clear;

VCL Reference

485

PrintDate CopyFrom method

Declaration

function CopyFrom(Source: TCrpePrintDate): boolean;

Description

The CopyFrom method copies the PrintDate property values from another TCrpePrintDate 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 PrintDate property values to a temporary TCrpePrintDate object:

var

tempPrintDate : TCrpePrintDate; begin

tempPrintDate := TCrpePrintDate.Create; tempPrintDate.CopyFrom(Crpe1.PrintDate); {...later, when finished with the temp object...} tempPrintDate.Free;

end;

PrintDate Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the PrintDate information from the Report. Returns True if the call succeeded.

NOTE: Since the PrintDate object also applies to Subreports, the Retrieve method will obtain the PrintDate for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the PrintDate settings 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 PrintDate settings for each Subreport.

Example

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

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

Crpe1.Margins.Retrieve;

VCL Reference

486

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