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

begin

Crpe1.SectionFont[cnt].Name := 'Times New Roman'; Crpe1.SectionFont[cnt].Size := 10; Crpe1.SectionFont[cnt].Weight := fwBold;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFont Methods

SectionFont Add method

Declaration

procedure Add(SectionName: TCrSectionFontSection);

Type

TCrSectionFontSection = string;

Description

The Add method adds an item to the SectionFont object and sets the internal index to that item. It requires a Section name as a parameter, which should be a name corresponding to a Section in the Report. Sections are named using the Short Section Name convention used in Crystal Reports (see About Section Names, Volume 1, Chapter 7 for more information). If the Add method is used, the steps to using SectionFont are:

1Add an item to the SectionFont object (you must specify the Section name).

2Fill the item's properties (Name, Size, etc.) with values.

3When Execute is called, the properties will be sent to the Print Engine.

NOTE: It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Section names are correct for the current Report.

Example

The Add method can be used to manually add an item to the SectionFont object, instead of using Retrieve:

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

{Specify Section Name - must be same as in Report} Crpe1.SectionFont.Add('Da'); Crpe1.SectionFont.Name := 'Times New Roman'; Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

540

SectionFont Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the SectionFont object. It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear is only applied to the SectionFont object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the SectionFont of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear.

Example

This code clears the SectionFont properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.SectionFont.Clear;

This code clears the SectionFont properties for all the Subreports:

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

Crpe1.Subreports[cnt];

Crpe1.SectionFont.Clear; end;

SectionFont CopyFrom method

Declaration

function CopyFrom(Source: TCrpeSectionFont): boolean;

Description

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

VCL Reference

541

Example

The following example copies all the SectionFont property values to a temporary TCrpeSectionFont object:

var

tempSectionFont : TCrpeSectionFont; begin

tempSectionFont := TCrpeSectionFont.Create; tempSectionFont.CopyFrom(Crpe1.SectionFont); {...later, when finished with the temp object...} tempSectionFont.Free;

end;

SectionFont Count method

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the SectionFont 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.SectionFont.Retrieve;

for cnt := 0 to (Crpe1.SectionFont.Count - 1) do Crpe1.SectionFont[cnt].Name := 'Times New Roman';

end;

SectionFont Create method

Declaration

constructor Create;

Description

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

VCL Reference

542

SectionFont Delete method

Declaration

procedure Delete(nIndex: integer);

Description

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

Example

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

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

{Specify Section Name - must be same as in Report} Crpe1.SectionFont.Add('Da'); Crpe1.SectionFont.Name := 'Times New Roman'; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SectionFont.Delete(0);

SectionFont 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.

SectionFont Retrieve method

Declaration

function Retrieve: boolean;

VCL Reference

543

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