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

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 changes to Graphs. In this case, there is a Graph in each of three sections (RH, GH1a, GH2a). Only the Graphs in the Group Headers should be changed, so the SectionType method can be used in an expression to apply the changes:

var

cnt: integer; begin

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

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

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

Crpe1.GraphText[cnt].Title := 'Company Graph';

end; end;

GraphText Send method

Declaration

function Send: boolean;

Description

The Send method sends the GraphText 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 GraphText settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.GraphText.Send;

VCL Reference

342

GraphType Properties

GraphType Item property

Declaration

property Item[const nIndex: integer]: TCrpeGraphType;

Description

The Item property is a default array property. It is read-only, and only available at runtime. It's primary use is to provide an easy way to navigate through the various items stored in the GraphType object, allowing the object to be treated like an array.

Item is a default property, so it does not need to be specified when using the subscript: GraphType[2] is the same as GraphType.Item[2].

Item returns a reference to itself, so the GraphType properties can be used right after the subscript: GraphType[2].Style := SideBySide;

Example

Since Item is a default array property, the following two blocks of code do the same thing:

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

{Set GraphType object to the 2nd graph} Crpe1.GraphType.Item[1];

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

{Set GraphType object to the 2nd graph} Crpe1.GraphType[1];

GraphType ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current GraphType item number, or set the GraphType object to another item.

VCL Reference

343

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox. This Index is updated whenever the Item property is used (GraphType[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.

Example

The following code illustrates the use of the ItemIndex property to make sure the GraphType object is pointing to the first GraphType item:

if Crpe1.GraphType.ItemIndex <> 0 then Crpe1.GraphType[0];

GraphType Number property

Declaration

property Number: TCrGraphTypeNumber;

Type

TCrGraphTypeNumber = integer;

Description

The Number property specifies the Graph Number.

If the Retrieve method is used to fill the GraphType object with information from the Report, each GraphType item will have a unique Graph Number assigned by the VCL.

If the manual Add method is used instead, a Graph number will have to be specified which corresponds to the Print Engine method of numbering Graphs (see How Graphs are Numbered, Page 37).

The primary use of the Number property is as a look-up to point the GraphType object to the item with the Graph number specified. The default array property, Item, however, provides an easier way to navigate through the object.

Example

This example retrieves the GraphType information from the Report and then changes the Style to 3D Bars:

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

if Crpe1.GraphType.Count > 0 then

VCL Reference

344

begin

{Set the GraphType object to Graph number 0} Crpe1.GraphType.Number := 0; Crpe1.GraphType.Style := ThreeDBars; Crpe1.Execute;

end;

GraphType Section property

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphType object is currently pointed to. It indicates in which Section of the Report that the Graph is located.

Note that you cannot move a Graph from one Section to another by changing this property. It should primarily be used as a read-only property after the GraphType information has been retrieved with the Retrieve method. If the manual Add method is used to add items to the GraphType object, then Section will have to be assigned the correct value in code.

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

RH - Report Header

PH - Page Header

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.

Example

This example retrieves the GraphType information from the Report and then changes the Style to 3D Bars only for those Graphs that reside in the Page Header:

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

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

if Crpe1.GraphType[cnt].Section = 'PH' then Crpe1.GraphType[cnt].Style := ThreeDBars;

end; Crpe1.Execute;

VCL Reference

345

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