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

Points = Twips / 20

Twips = Points * 20

Inches = Points / 72

Points = Inches * 72

Example

The code below retrieves the SectionHeight settings from the Report, then loops through looking for the Details "a" section, and sets the Height for that Section:

var

cnt: integer; begin

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

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

{Look for Details area}

if Crpe1.SectionHeight[cnt].Section = 'Da' then Crpe1.SectionHeight[cnt].Height := 400;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionHeight Item property

Declaration

property Item[const nIndex: integer]: TCrpeSectionHeight;

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

Item returns a reference to itself, so the SectionHeight properties can be used right after the subscript: SectionHeight[2].Height:= 300;

VCL Reference

586

Example

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

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

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

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

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

SectionHeight ItemIndex property

Declaration

property ItemIndex: integer;

Description

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

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

SectionHeight Section property

Declaration

property Section: TCrSectionHeightSection;

VCL Reference

587

Type

TCrSectionHeightSection = string;

Description

The Section property contains the Section name of the item that the SectionHeight object is currently pointed to. It's primary use is as a look-up property to point the SectionHeight object to the item with the Section specified. The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the Section name of each SectionHeight item is automatically filled when the SectionHeight information is retrieved.

The Section name syntax is the same as the Short Section Names used in the Crystal Reports Designer:

RH - Report Header

PH - Page Header

GH - Group Header

D - Details

GF - Group Footer

PF - Page Footer

RF - Report Footer

Lower-case letters: a, b, c, etc. are used to specify sub-sections. Numbers are used to designate different Groups: GH1, GF2, etc. See About Section Names, Volume 1, Chapter 7, for more details on the syntax.

Example

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

var

cnt: integer; begin

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

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

{Look for Details area}

if Crpe1.SectionHeight[cnt].Section = 'Da' then Crpe1.SectionHeight[cnt].Height := 400;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

588

SectionHeight SectionAsCode property

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers. Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names, Volume 1, Chapter 7.

Example

The SectionAsCode property can be used to apply formatting to specific sections based on mathematical calculations or comparisons. The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc., and if it is, the SectionHeight is changed to 500 twips:

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

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

if (Crpe1.SectionHeight[cnt].SectionAsCode mod 1000 = 25) then Crpe1.SectionHeight[cnt].Height := 500;

end; Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers). So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc. Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section. This also works for all the other sections that do not have Group options, such as Details, ReportHeader, etc. since dividing by 25 will also return no remainder if the Section Code number is evenly divisible by 1000.

SectionHeight Methods

SectionHeight Add method

Declaration

procedure Add(SectionName: TCrSectionHeightSection);

VCL Reference

589

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