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

Sub-Class Properties and Methods

AreaFormat Properties

AreaFormat Hide property

Declaration

property Hide: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

Hide determines if the specified Area will show or not. A hidden section is still available for drill-down in the Preview Window (provided that the drill-down options are turned on in the WindowButtonBar object). To suppress an Area so that it is not available for drill-down, use the Suppress property.

Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the Hide option for that area:

var

cnt: integer; begin

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

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

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then Crpe1.AreaFormat[cnt].Hide := cTrue;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

214

AreaFormat Item property

Declaration

property Item[const nIndex: integer]: TCrpeAreaFormat;

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 various items stored in the AreaFormat 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: AreaFormat[2] is the same as AreaFormat.Item[2].

Item returns a reference to itself, so the AreaFormat properties can be used right after the subscript: AreaFormat[2].Hide := True;

Example

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

Crpe1.ReportName := 'C:\MyReport.rpt'; Crpe1.AreaFormat.Retrieve;

{Set AreaFormat to the 3rd area} Crpe1.AreaFormat.Item[2];

Crpe1.ReportName := 'C:\MyReport.rpt'; Crpe1.AreaFormat.Retrieve;

{Set AreaFormat to the 3rd area} Crpe1.AreaFormat[2];

AreaFormat ItemIndex property

Declaration

property ItemIndex: integer;

Description

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

VCL Reference

215

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 (AreaFormat[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 AreaFormat object is pointing to the first AreaFormat item:

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

AreaFormat KeepTogether property

Declaration

property KeepTogether: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

KeepTogether determines whether an Area which is printing fields from the same Record will be split on a Page Break or not. For example, if a Details area has fields placed on 4 horizontal lines, setting KeepTogether to cTrue will ensure that those fields will not be split when a Page Break occurs, by moving them all to the new page.

NOTE: The AreaFormat KeepTogether property is not the same as Crystal Reports' KeepGroupTogether option, which keeps a Group from splitting on a Page Break, and which is available via the KeepTogether property of the GroupOptions object.

Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the KeepTogether option for that area:

var

cnt: integer; begin

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

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

VCL Reference

216

begin

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then Crpe1.AreaFormat[cnt].KeepTogether := cTrue;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

AreaFormat NewPageAfter property

Declaration

property NewPageAfter: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

NewPageAfter determines if a Page Break will occur after the specified Area.

Example

The code below retrieves the AreaFormat settings from the Report, then loops through looking for the Details area, and sets the NewPageAfter option for that area:

var

cnt: integer; begin

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

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

{Look for Details area}

if Crpe1.AreaFormat[cnt].Section = 'D' then Crpe1.AreaFormat[cnt].NewPageAfter := cTrue;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

217

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