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

{Loop through Reports and Retrieve}

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

Crpe1.Subreports[cnt];

Crpe1.GroupSelection.Retrieve; end;

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

end;

GroupSelection Send method

Declaration

function Send: boolean;

Description

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

Crpe1.GroupSelection.Send;

GroupSortFields Properties

GroupSortFields DeleteGSF property

Declaration

property DeleteGSF: boolean;

VCL Reference

387

Description

The DeleteGSF property can be used to remove a GroupSortField from a Report. The GroupSortField is not actually removed from the Report until the Execute method is called. After Execute is called, the GroupSortField is also removed from the VCL.

NOTE: DeleteGSF is not the same as Delete. Delete removes a GroupSortField item from the GroupSortFields object, not from the Report.

Example

This example will remove the second GroupSortField from a Report when that Report is run:

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

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields[1].DeleteGSF := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

GroupSortFields Direction property

Declaration

property Direction: TCrSortDirection;

Type

TCrSortDirection = (sdDescending, sdAscending, sdDefault);

Description

The Direction property determines the Sort Order, which can either be sdDescending (9..0, Z..A), sdAscending (0..9, A..Z), or sdDefault (no change).

Example

This example changes the Sort Order of the first GroupSortField to ascending:

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

Crpe1.GroupSortFields.Retrieve;

Crpe1.GroupSortFields[0].Direction := sdAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

388

GroupSortFields Field property

Declaration

property Field: string;

Description

The Field property specifies the summary field that will control sorting. Summary fields are usually constructed in this fashion:

SummaryFunction(DatabaseField,GroupingField)

so they usually look something like this:

Sum({company.SALES},{company.STATE})

This would read: "Sum of the Company's Sales per State". The last parameter must be a field that the Report is grouped on.

Enclose field names in braces: {company.STATE}.

If a formula field is the grouping field, use the @ sign before the formula name: {@FormulaName}.

Example

This example changes the second GroupSortField:

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

Crpe1.GroupSortFields[1].Field := 'Sum({company.SALES},{company.STATE})'; Crpe1.Output := toWindow;

Crpe1.Execute;

GroupSortFields Item property

Declaration

property Item[const nIndex: integer]: TCrpeGroupSortFields;

VCL Reference

389

Description

The Item property is a default array property. It is read-only, and only available at runtime. Its primary use is to provide an easy way to navigate through the various items stored in the GroupSortFields 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: GroupSortFields[2] is the same as GroupSortFields.Item[2].

Item returns a reference to itself, so the GroupSortFields properties can be used right after the subscript: GroupSortFields[2].Direction := sdAscending;

Example

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

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

{Set GroupSortFields object to the 3rd item} Crpe1.GroupSortFields.Item[2]; Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GroupSortFields.Retrieve;

{Set GroupSortFields object to the 3rd item} Crpe1.GroupSortFields[2];

GroupSortFields ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GroupSortFields item number, or set the GroupSortFields object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox. This Index is updated whenever the Item property is used (GroupSortFields[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.

VCL Reference

390

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