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

{Check for Details area}

if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then begin

{Choose the Suppress formula} Crpe1.SectionFormatFormulas[cnt].Name := sfSuppress; {Clear it from any retrieved formula} Crpe1.SectionFormatFormulas[cnt].Formula.Clear;

{Add the new formula} Crpe1.SectionFormatFormulas[cnt].Formula.Add('{company.STATE}

= "CA"'); Break;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

SectionFormatFormulas NameIndex property

Declaration

property NameIndex: integer

Description

The NameIndex property is a Run-time only property which can be used to obtain the current Formula Name item number, or set the Formula Name list to another item.

Comparison of Properties for Section Items and Name Items:

The SectionFormatFormulas object contains an internal Index which determines which Section item it is currently looking at. This index is changed via the Section, Item, and ItemIndex properties, and can be read via the IndexOf method.

Likewise, since each Section contains numerous Formula Name items, these are controlled via a secondary internal Index which is changed via the Name, Names, and NameIndex properties, and can be read via the IndexOfName method.

That is,

Sections

Names

 

 

Section

Name

Item

Names

 

 

ItemIndex

NameIndex

 

 

IndexOf

IndexOfName

 

 

Count

NameCount

VCL Reference

570

Example

This example checks the NameIndex of the Formula names list and sets it to the first item if it is not currently pointing to that item:

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

Crpe1.SectionFormatFormulas.Retrieve;

if Crpe1.SectionFormatFormulas[0].NameIndex <> 0 then Crpe1.SectionFormatFormulas[0].NameIndex := 0;

SectionFormatFormulas Names property

Declaration

property Names[nIndex: integer]: TCrSectionFormatFormula

Type

TCrSectionFormatFormula = (sfSuppress, sfPrintAtBottomOfPage, sfNewPageBefore, sfNewPageAfter, sfResetPageNAfter, sfKeepTogether, sfSuppressBlankSection, sfUnderlaySection, sfBackgroundColor);

Description

The Names property can be used to step through the Formula Name items of an SectionFormatFormulas item by numerical subscript. It is useful in looping constructs, to gather all the Formula Names that apply to a particular Section. In this case, it should be used along with the NameCount method, to avoid a "Subscript out of bounds" error.

Comparison of Properties for Section Items and Name Items:

The SectionFormatFormulas object contains an internal Index which determines which Section item it is currently looking at. This index is changed via the Section, Item, and ItemIndex properties, and can be read via the IndexOf method.

Likewise, since each Section contains numerous Formula Name items, these are controlled via a secondary internal Index which is changed via the Name, Names, and NameIndex properties, and can be read via the IndexOfName method.

That is,

Sections

Names

 

 

Section

Name

 

 

Item

Names

 

 

ItemIndex

NameIndex

 

 

IndexOf

IndexOfName

Count

NameCount

 

 

VCL Reference

571

Example

The Names property is used in the example below, to loop through the Formula items for the Page Header section, sending the Formula names to a ListBox:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.AreaFormatFormulas.Retrieve; Crpe1.AreaFormatFormulas.Section := 'PH';

for cnt := 0 to (Crpe1.AreaFormatFormulas.NameCount - 1) do begin

case Ord(Crpe1.AreaFormatFormulas.Names[cnt]) of

0:ListBox1.Items.Add('afHide');

1:ListBox1.Items.Add('afSuppress');

2:ListBox1.Items.Add('afPrintAtBottomOfPage');

3:ListBox1.Items.Add('afNewPageBefore');

4:ListBox1.Items.Add('afNewPageAfter');

5:ListBox1.Items.Add('afResetPageNAfter');

6:ListBox1.Items.Add('afKeepTogether');

end; end;

end;

SectionFormatFormulas Section property

Declaration

property Section: TCrSectionFormatFormulasSection;

Type

TCrSectionFormatFormulasSection = string;

Description

The Section property specifies the Report Section name that the Formula will apply to. The property acts as a look-up, to point the SectionFormatFormulas object to the item with the Section specified. The Retrieve method can be used to fill the SectionFormatFormulas object with information from the Report, thus filling the Section property with appropriate values.

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

RH - Report Header

PH - Page Header

VCL Reference

572

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.

NOTE: Whereas objects such as AreaFormat and AreaFormatFormulas work on certain areas, for example, the Details area, SectionFormat and SectionFormatFormulas work on specific individual sub-sections, such as Details "a", Details "b", etc. The options set in these objects affect only the particular sub-section specified by the Section property.

Example

This example retrieves the SectionFormatFormula information, then assigns a Suppress formula to the Details "a" section, so that the section will be suppressed if the State is California:

Crpe1.ReportName := 'Company.rpt'; Crpe1.SectionFormatFormulas.Retrieve; {Loop through the Areas}

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

{Check for Details area}

if Crpe1.SectionFormatFormulas[cnt].Section = 'Da' then begin

{Choose the Suppress formula} Crpe1.SectionFormatFormulas[cnt].Name := sfSuppress; {Clear it from any retrieved formula} Crpe1.SectionFormatFormulas[cnt].Formula.Clear;

{Add the new formula} Crpe1.SectionFormatFormulas[cnt].Formula.Add('{company.STATE}

= "CA"'); Break;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

SectionFormatFormulas SectionAsCode property

Declaration

property SectionAsCode: smallint;

VCL Reference

573

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