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

Description

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

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

Example

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

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

Crpe1.Margins.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.Margins.Retrieve; end;

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

end;

Margins Send method

Declaration

function Send: boolean;

Description

The Send method sends the Margins 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.

VCL Reference

431

Example

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

Crpe1.Margins.Send;

Pages Properties

Pages Item property

Declaration

property Item[const nIndex: integer]: string;

Description

The Item property is a default array property. It is read-only, and only available at runtime. It's primary use is to provide an easy way to navigate through the Pages object, allowing the object to be treated like an array.

Item is a default property, so it does not need to be specified when using the subscript: Pages[2] is the same as Pages.Item[2].

Example

Since Item is a default array property, the following two blocks of code do the same thing:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toWindow; Crpe1.Execute;

{Set Window to view 3rd page} Crpe1.Pages.Item[2];

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toWindow; Crpe1.Execute;

{Set Window to view 3rd page} Crpe1.Pages[2];

Pages ItemIndex property

Declaration

property ItemIndex: integer;

VCL Reference

432

Description

ItemIndex is a Run-time only property which can be used to read the current Page (same as GetDisplayed), or set the current Page (same as GoToPage).

Example

This code sample illustrates the use of ItemIndex to show and set the page displayed:

var

pg1: integer; begin

{Get the Displayed page number} pg1 := Crpe1.Pages.ItemIndex; {Show the next page} Crpe1.Pages.ItemIndex := pg1 + 1;

end;

Pages Methods

Pages Count method

Declaration

function Count: SmallInt;

Description

Count returns the number of Pages in the Report. This will return 0 until Execute is called.

Example

The following code shows how to get the number of Pages in a Report using the Count property:

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

Crpe1.Output := toWindow;

Crpe1.Execute;

ShowMessage(IntToStr(Crpe1.Pages.Count));

Pages First method

Declaration

procedure First;

VCL Reference

433

Description

The First method causes the Preview Window to go to the first Page of the Report. This method can be used to simulate the action of the First Page button on the Preview Window.

Example

The following code shows how to use the First method to go to the first Page of a Report:

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

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.Pages.First;

Pages GetDisplayed method

Declaration

function GetDisplayed: Word;

Description

GetDisplayed will return the number of the currently active (or previewed) Page.

Example

The following code shows how to get the Displayed Page of a Report:

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

Crpe1.Output := toWindow;

Crpe1.Execute;

ShowMessage(IntToStr(Crpe1.Pages.GetDisplayed));

Pages GetLatest method

Declaration

function GetLatest: Word;

Description

GetLatest will return the number of the highest Page that has been built so far. When going to Preview Window, all the database records are read, but only the Pages required are built (to speed up the display for large Reports). This is why the Page count display always starts with "Page 1 of 1+". As the Next Page button is pressed, each page will be built and added to the count, or if the Last Page button is pressed, all the Pages will be built.

VCL Reference

434

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