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

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;

SectionFormat Item property

Declaration

property Item[const nIndex: integer]: TCrpeSectionFormat;

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

Item returns a reference to itself, so the SectionFormat properties can be used right after the subscript: SectionFormat[2].BackgroundColor := clRed;

Example

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

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.SectionFormat.Retrieve;

{Set SectionFormat to the 3rd section} Crpe1.SectionFormat.Item[2];

VCL Reference

548

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.SectionFormat.Retrieve;

{Set SectionFormat to the 3rd section} Crpe1.SectionFormat[2];

SectionFormat ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current SectionFormat item number, or set the SectionFormat 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 (SectionFormat[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 SectionFormat object is pointing to the first SectionFormat item:

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

SectionFormat KeepTogether property

Declaration

property KeepTogether: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

VCL Reference

549

Description

KeepTogether determines whether a Section which is printing fields from the same Record will be split on a Page Break or not. For example, if a Details section 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 SectionFormat 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 SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the KeepTogether option for that section:

var

cnt: integer; begin

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

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

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then Crpe1.SectionFormat[cnt].KeepTogether := cTrue;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormat NewPageAfter property

Declaration

property NewPageAfter: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

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

VCL Reference

550

Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the NewPageAfter option for that section:

var

cnt: integer; begin

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

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

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then Crpe1.SectionFormat[cnt].NewPageAfter := cTrue;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormat NewPageBefore property

Declaration

property NewPageBefore: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

NewPageBefore determines if a Page Break will occur before the specified Section.

Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the NewPageBefore option for that section:

var

cnt: integer; begin

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

VCL Reference

551

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