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

Description

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

NOTE: There is currently no way to obtain Font information from the Print Engine at runtime so Retrieve simply adds an item to the SectionFont object for each Report Section it finds, obtains the current Section Code for the Section property, and sets the other properties to default values.

NOTE: Since the SectionFont object also applies to Subreports, the Retrieve method will obtain the SectionFont for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the SectionFont 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 SectionFont information for each Subreport (see Example).

Example

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

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

Crpe1.SectionFont.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.SectionFont.Retrieve; end;

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

end;

SectionFont SectionType method

Declaration

function SectionType: string;

VCL Reference

544

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.

Example

The following example uses the SectionType method to apply conditional formatting. In this case, we want to change the Font style for the Group Header sections only:

var

cnt: integer; begin

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

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

{if the SectionType is Group Header, apply the change} if (Crpe1.SectionFont[cnt].SectionType = 'GH') then

Crpe1.SectionFont[cnt].Name := 'Times New Roman';

end; end;

SectionFont Send method

Declaration

function Send: boolean;

Description

The Send method sends the SectionFont values to the Crystal Reports Print Engine. This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

It is strongly recommended that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine. If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method. This feature is mainly provided for debugging purposes.

Example

In this example, the SectionFont settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.SectionFont.Send;

VCL Reference

545

SectionFormat Properties

SectionFormat BackgroundColor property

Declaration

property BackgroundColor: TColor;

Description

BackgroundColor specifies the color that will fill the background of a specified section on the Report. The value can be any of the Delphi color constants, the Color value returned from Delphi's Color Dialog, or the following constants:

clUnchangedColor -2

clNoColor

$FFFFFFFF

Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets the BackgroundColor 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].BackgroundColor := clRed;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormat FreeFormPlacement property

Declaration

property FreeFormPlacement: TCrBoolean;

VCL Reference

546

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

FreeFormPlacement determines if objects in a specified Section can be placed anywhere, or whether they snap to the page grid.

Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets FreeFormPlacement 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].FreeFormPlacement := cTrue;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormat Hide property

Declaration

property Hide: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

Hide determines if the specified Area will show or not. A hidden section is still available for drill-down in the Preview Window (provided that the drill-down options are turned on in the WindowButtonBar object). To suppress an Area so that it is not available for drill-down, use the Suppress property.

VCL Reference

547

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