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

Subreports Count method

Declaration

function Count: integer;

Description

Count returns the number of Subreports. It includes the Main Report, and so a Count value of 1 means that there is only one main Report and no Subreports. Likewise, Subreports[0] refers to the main Report. When dealing with Subreports, be sure to call the Retrieve method before using Count. This will ensure a meaningful value.

Example

The following code fills a list box with all the Subreport Names. The count is started with 1 since 0 refers to the main Report:

Crpe1.Subreports.Retrieve;

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

Crpe1.Subreports[cnt1];

ListBox1.Items.Add(Crpe1.Subreports.Name); end;

Subreports Create method

Declaration

constructor Create;

Description

The Create constructor creates the Subreports object. It is used internally in the VCL component to create the Subreports object and should not be called outside of the component.

Subreports Delete method

Declaration

procedure Delete(nIndex: integer);

VCL Reference

658

Description

The Add and Delete methods provide a manual method of maintaining the Subreport items in the Subreports object of the VCL. We recommend that you use the Retrieve method instead as it is much easier and less errorprone. The Delete method removes an item from the Subreports object. If that item was the currently selected one, it sets the Subreports index to the previous item. It requires a valid Subreport item number as a parameter.

This method will not remove a Subreport from a Report; it only works on the VCL's internal data arrays.

Example

This example adds a new Subreport called 'SubRpt1' to the Subreports object, runs the Subreport, and then finally deletes the Subreport item from the Subreports object:

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

{Specify Subreport Name - must be same as in Report} Crpe1.Subreports.Add('SubRpt1'); Crpe1.Subreports.SubExecute := True;

Crpe1.Output := toWindow; Crpe1.Execute;

{Delete the Subreport item from the VCL} Crpe1.Subreports.Delete(1);

Subreports Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method frees the Subreports object. It is used internally in the VCL component to destroy the Subreports object and should not be called outside of the component.

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.

Subreports IndexOf method

Declaration

function IndexOf(SubName: TCrSubreportName): integer;

VCL Reference

659

Type

TCrSubreportName = string[128];

Description

The IndexOf method takes a Subreport name and returns the index position of the Subreport item in the current Subreports object.

After the Retrieve method has been called, the Subreports object contains one item for each Subreport in the Report. The IndexOf method can be used to determine if a given Subreport Name actually exists in the Subreports object before trying to access it.

Example

The following code illustrates the use of the IndexOf method to locate a specific Subreport item by it's name:

var

nItem: integer; begin

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

{Find a specific Subreport}

nItem := Crpe1.Subreports.IndexOf('SubreportOne');

{If it exists, retrieve the Formulas for that Subreport} if nItem > -1 then

begin

with Crpe1.Subreports[nItem] do Formulas.Retrieve;

end; end;

Subreports Retrieve method

Declaration

function Retrieve: boolean;

Description

Retrieve obtains Subreport information from a Report. It returns True if the call was successful, and False if it did not find any Subreports. Retrieve will get the Name, and Section of each Subreport, and allocate memory to store further Subreport details. It does not retrieve everything about a Subreport, such as Selection Formula, Section Information, Table information, etc. These must all be retrieved individually using their associated objects.

VCL Reference

660

If you intend to work with Subreports, then this method is the first one that should be called. After calling it, a loop can be set up which will go through all the Reports and retrieve the desired data from each one (see Example).

NOTE: Retrieve will clear out any current Subreport information, so it should not be called more than once during the process of running a Report.

Example

The following code illustrates the use of the Retrieve method for obtaining Subreport items, and then looping through the Subreports to retrieve other information:

var

cnt: integer; begin

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

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

Crpe1.Subreports[cnt];

Crpe1.Tables.Retrieve;

Crpe1.Selection.Retrieve;

Crpe1.SortFields.Retrieve;

Crpe1.GraphType.Retrieve; end;

end;

SummaryInfo Properties

SummaryInfo AppName property

Declaration

property AppName: TCrSummaryString;

Type

TCrSummaryString = string[128];

Description

AppName is a Read-only, Run-time only property which indicates which application created the Report. This property will only have a value if the Retrieve method is called beforehand.

VCL Reference

661

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