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

GraphText ItemIndex property

Declaration

property ItemIndex: integer;

Description

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

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 (GraphText[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 GraphText object is pointing to the first GraphText item:

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

GraphText Number property

Declaration

property Number: TCrGraphTextNumber;

Type

TCrGraphTextNumber = integer;

Description

The Number property specifies the Graph Number.

If the Retrieve method is used to fill the GraphText object with information from the Report, each GraphText 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).

VCL Reference

330

The primary use of the Number property is as a look-up to point the GraphText 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

The following example uses the Number property to navigate the GraphText object to a specific item whose properties are then changed:

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

if Crpe1.GraphText.Count > 0 then begin

Crpe1.GraphText.Number := 0; Crpe1.GraphText.XAxisTitle := 'New XAxis Title'; Crpe1.GraphText.YAxisTitle := 'New YAxis Title'; Crpe1.GraphText.ZAxisTitle := 'New ZAxis Title';

end;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphText Section property

Declaration

property Section: string;

Description

The Section property contains the Section name of the item that the GraphText 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 GraphText information has been retrieved with the Retrieve method. If the manual Add method is used to add items to the GraphText 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

 

 

VCL Reference

331

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

The Section property can be used to apply conditional changes to GraphText (i.e. only those items that are in the Page Header are affected in the following example):

var

cnt: integer; begin

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

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

if Crpe1.GraphText[cnt].Section = 'PH' then begin

Crpe1.GraphText[cnt].XAxisTitle := 'New XAxis Title'; Crpe1.GraphText[cnt].YAxisTitle := 'New YAxis Title'; Crpe1.GraphText[cnt].ZAxisTitle := 'New ZAxis Title';

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

GraphText SectionAsCode property

Declaration

property SectionAsCode: smallint;

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers. Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names, Volume 1, Chapter 7.

VCL Reference

332

Example

The following example uses the SectionAsCode property to apply conditional changes to Graphs. In this case, there is a Graph in each of three Group Header sections (GH1a, GH2a, GH3a). Since the Section Code for GH1a is 3000, GH2a is 3001, and GH3a is 3002, it is possible to do a simple mathematical calculation on the remainder of the Section Code divided by 1000 to change the Title of the Graph only if it is not in GH1:

var

cnt: integer; begin

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

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

{if the remainder of the SectionCode divided by 1000 is greater than zero, then apply the change}

if (Crpe1.GraphText[cnt].SectionAsCode mod 1000 > 0) then Crpe1.GraphText[cnt].Title := 'Sub-Group Graph';

end; end;

GraphText SeriesTitle property

Declaration

property SeriesTitle: TCrGraphTextType;

Type

TCrGraphTextType = string[128];

Description

The SeriesTitle property specifies the title of the Series which is being graphed.

Example

The following example retrieves the GraphText information from the Report, then changes the SeriesTitle for the first Graph:

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

if Crpe1.GraphText.Count > 0 then Crpe1.GraphText[0].SeriesTitle := 'New Series Title';

Crpe1.Output := toWindow; Crpe1.Execute;

VCL Reference

333

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