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

GroupCondition Item property

Declaration

property Item[const nIndex: integer]: TCrpeGroupCondition;

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 GroupCondition 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: GroupCondition[2] is the same as GroupCondition.Item[2].

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

Example

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

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

{Set GroupCondition to the 3rd Group} Crpe1.GroupCondition.Item[2];

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

{Set GroupCondition to the 3rd Group} Crpe1.GroupCondition[2];

GroupCondition ItemIndex property

Declaration

property ItemIndex: integer;

Description

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

VCL Reference

358

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 (GroupCondition[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.

Example

The following code illustrates the use of the ItemIndex property to make sure the GroupCondition object is pointing to the first GroupCondition item:

if Crpe1.GroupCondition.ItemIndex <> 0 then Crpe1.GroupCondition[0];

GroupCondition Number property

Declaration

property Number: TCrGroupConditionNumber;

Type

TCrGroupConditionNumber = integer;

Description

The Number property specifies the Group Number. Unlike most of the other properties, Number is one-based, therefore the first Group is number one (1).

Number is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the GroupCondition object to point to the GroupCondition item that has a Number with the same value.

Before using the Number property to navigate through the GroupCondition, the Retrieve method should be called, or the manual Add method.

Example

This sample retrieves the GroupCondition values from the Report, and uses the Number property to set the first Group to the {company.STATE} field:

Crpe1.ReportName := 'C:\Company.rpt'; with Crpe1.GroupCondition do

begin

Retrieve;

VCL Reference

359

Number := 1;

Field := '{company.STATE}'; Condition := AnyChange; Direction := gcAscending;

end; Crpe1.Execute;

GroupCondition Methods

GroupCondition Add method

Declaration

procedure Add(GroupNumber: TCrGroupConditionNumber);

Type

TCrGroupConditionNumber = integer;

Description

The Add method adds an item to the GroupCondition object and sets the internal index to that item. It requires a GroupCondition number as a parameter, which should be a number corresponding to a Group in the Report.

Unlike most other properties, Groups are numbered starting from one (1), although the GroupCondition object is still zero-based (i.e. GroupCondition[0].Number usually equals 1).

If the Add method is used, the steps to using GroupCondition are:

1Add an item to the GroupCondition object (you must specify the Group number).

2Fill the item's properties (Field, Direction, etc.) with values.

3When Execute is called, the properties will be sent to the Print Engine.

NOTE: It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the GroupCondition numbers are correct for the current Report.

Example

The Add method can be used to manually add an item to the GroupCondition object, instead of using Retrieve. Remember that the first Group number that can be added is 1, not 0 as in most other cases:

Crpe1.ReportName := 'C:\Company.rpt'; {Specify Group Number} Crpe1.GroupCondition.Add(1);

Crpe1.GroupCondition.Field := '{company.STATE}'; Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

360

GroupCondition Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GroupCondition object. It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the GroupCondition object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the GroupCondition of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.

Example

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

Crpe1.GroupCondition.Clear;

This code clears the GroupCondition properties for all the Subreports:

IRU FQW WR &USH 6XEUHSRUWV &RXQW GR begin

Crpe1.Subreports[cnt];

Crpe1.GroupCondition.Clear; end;

GroupCondition CopyFrom method

Declaration

function CopyFrom(Source: TCrpeGroupCondition): boolean;

Description

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

VCL Reference

361

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