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

SectionFormatFormulas Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the SectionFormatFormulas object. The "nIndex" parameter represents the number of the item in the SectionFormatFormulas object.

Example

The Delete method can be used to manually remove an item from the SectionFormatFormulas object:

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

{Specify Section Name - must be same as in Report} Crpe1.SectionFormatFormulas.Add('PH'); Crpe1.SectionFormatFormulas.Name := afSuppress; Crpe1.SectionFormatFormulas.Formula.Text := 'True'; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionFormatFormulas.Delete(0);

SectionFormatFormulas Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method frees the SectionFormatFormulas object. It is used internally in the VCL component to destroy the SectionFormatFormulas object when the component is destroyed, and should not be called outside of the component.

NOTE: The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it. The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.

VCL Reference

578

SectionFormatFormulas IndexOf method

Declaration

function IndexOf(SectionName: TCrSectionFormatFormulasSection): integer;

Type

TCrSectionFormatFormulasSection = string;

Description

The IndexOf method takes a Section name and returns the index position of the Section item in the current SectionFormatFormulas object.

After the Retrieve method has been called, the SectionFormatFormulas object contains one item for each Section in the Report. This could be illustrated like so (the Section items in your Reports may not be the same):

SectionFormatFormulas - Section items

¾RHa

¾RHb

¾PH

¾GH1

¾GH2a

¾GH2b

¾D

¾GF2b

¾GF2a

¾GF1

¾PF

¾RFa

¾RFb

The IndexOf method can be used to determine if a given Section Name actually exists in the SectionFormatFormulas object before trying to access it.

VCL Reference

579

Example

The following code illustrates the use of the IndexOf method to locate a specific Section:

var

nItem: integer; begin

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

Crpe1.SectionFormatFormulas.Retrieve; {Find Details "a" section}

nItem := Crpe1.SectionFormatFormulas.IndexOf('Da'); {If it exists...}

if nItem > -1 then begin

with Crpe1.SectionFormatFormulas[nItem] do begin

{Suppress section if STATE is California} Name := sfSuppress;

Formula.Text := '{company.STATE} = "CA"'; end;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormatFormulas IndexOfName method

Declaration

function IndexOfName(FormulaName: TCrSectionFormatFormula): integer;

Type

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

Description

The IndexOfName method takes a SectionFormatFormula name and returns the index position of the Formula item in the current Section item of the SectionFormatFormulas object. See the explanation of the Name property for more details.

VCL Reference

580

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.

Sections

Names

Section

Name

 

 

Item

Names

 

 

ItemIndex

NameIndex

 

 

IndexOf

IndexOfName

 

 

Count

NameCount

Example

This example uses the IndexOfName method to update a ListBox of Formula Names for the Details Section:

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

Crpe1.SectionFormatFormulas.Retrieve;

{Set SectionFormatFormulas object to Details item} Crpe1.SectionFormatFormulas.Section := 'D';

{Loop through and get formula names}

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

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

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

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

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

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

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

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

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

7:ListBox1.Items.Add('UnderlaySection');

8:ListBox1.Items.Add('BackgroundColor');

end; end;

{Set Formulas Index to UnderlaySection} Crpe1.SectionFormatFormulas.Name := sfUnderlaySection; {Get Index number}

nItem := Crpe1.SectionFormatFormulas.IndexOfName(sfUnderlaySection); {Update ListBox with Index}

ListBox1.ItemIndex := nItem;

VCL Reference

581

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