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

SectionFormat CopyFrom method

Declaration

function CopyFrom(Source: TCrpeSectionFormat): boolean;

Description

The CopyFrom method copies the SectionFormat property values from another TCrpeSectionFormat object. It is similar to Delphi's Assign method. It is useful for transferring or temporary storage of values.

Example

The following example copies all the SectionFormat property values to a temporary TCrpeSectionFormat object:

var

tempSectionFormat : TCrpeSectionFormat; begin

tempSectionFormat := TCrpeSectionFormat.Create; tempSectionFormat.CopyFrom(Crpe1.SectionFormat); {...later, when finished with the temp object...} tempSectionFormat.Free;

end;

SectionFormat Count property

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SectionFormat object. It is handy for setting up loops to make similar changes to each item.

Example

The Count method is useful for looping constructions. You would normally want to call Retrieve first:

var

cnt: integer; begin

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

VCL Reference

560

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

{Look for Details "a" section}

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

Crpe1.SectionFormat[cnt].BackgroundColor := clRed; Crpe1.SectionFormat[cnt].FreeFormPlacement := cTrue; Crpe1.SectionFormat[cnt].KeepTogether := cTrue; Crpe1.SectionFormat[cnt].ResetPageNAfter := cFalse; Crpe1.SectionFormat[cnt].Suppress := cTrue; Crpe1.SectionFormat[cnt].SuppressBlankSection := cTrue;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormat Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the SectionFormat object, and does not need to be called in code.

SectionFormat Delete method

Declaration

procedure Delete(nIndex: integer);

Description

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

VCL Reference

561

Example

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

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

{Specify Section Name - must be same as in Report} Crpe1.SectionFormat.Add('Da'); Crpe1.SectionFormat.BackgroundColor := clRed; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionFormat.Delete(0);

SectionFormat Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

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.

SectionFormat Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the SectionFormat information from the Report and stores it in the SectionFormat object. If no SectionFormat information was found, the call returns False. Be aware that calling Retrieve will first cause the SectionFormat object to be cleared, so any current information stored in it will be removed.

NOTE: Since the SectionFormat object also applies to Subreports, the Retrieve method will obtain the SectionFormat for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the SectionFormat information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item. The VCL will store separate SectionFormat information for each Subreport (see Example).

VCL Reference

562

Example

The following code illustrates the use of the Retrieve method for the main Report:

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

Crpe1.SectionFormat.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

cnt: integer; begin

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

{Loop through Reports and Retrieve}

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

Crpe1.Subreports[cnt];

Crpe1.SectionFormat.Retrieve; end;

{Set Crpe component back to main Report} Crpe1.Subreports[0];

end;

SectionFormat SectionType method

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier. In other words, if the Section Code for an item is GH1ac, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier. See the Example for an illustration.

Example

The following example uses the SectionType method to apply conditional formatting to Sections. In this case, the formatting is only to apply to Group Header sections:

var

cnt: integer; begin

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

VCL Reference

563

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