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

GraphType 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 use them in mathematical expressions or relationships than to the actual Section names (GH1b, etc.).

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

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 style of the Graphs only if it is not in GH1:

var

cnt: integer; begin

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

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

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

if (Crpe1.GraphType[cnt].SectionAsCode mod 1000 > 0) then Crpe1.GraphType[cnt].Style := Pie;

end; end;

GraphType Style property

Declaration

property Style: TCrGraphType;

Type

TCrGraphType = (SideBySide, ThreeDSide, StackedBar, ThreeDStacked, PercentBar, ThreeDPercent, Line, Area, ThreeDBars, Pie, MultiplePie, WeightedPie, UserDefined, UnknownGraph);

VCL Reference

346

Description

The Style property determines the type of Graph that will be displayed in the Report. The different Styles are illustrated below:

The UserDefined and UnknownGraph types represent the following:

UserDefined

- The Graph has been edited in PG Editor. Some of the Graph changes via the VCL

 

may not affect options that have been customized in PG Editor.

UnknownGraph - The Print Engine cannot recognize the Graph. This shouldn't happen, but if it does, it is likely that changes to the Graph via the VCL may not work properly. In this case, the Report should be opened in Crystal Reports and re-saved, or the Graph should

be re-inserted.

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 begin

Crpe1.GraphType[0].Style := ThreeDBars; Crpe1.Execute;

end;

VCL Reference

347

GraphType Methods

GraphType Add method

Declaration

procedure Add(GraphNumber: TCrGraphTypeNumber);

Type

TCrGraphTypeNumber = integer;

Description

The Add method adds an item to the GraphType object and sets the internal index to that item. It requires a Graph number as a parameter, which should be a number corresponding to a Graph in the Report. Graphs are numbered starting from zero, from the top of the Report down, and left to right in each Section. If the Add method is used, the steps to using GraphType are:

1Add an item to the GraphType object (you must specify the Graph number).

2Fill the item's properties (Section, Style, 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 Graph numbers are correct for the current Report.

Example

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

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

{Specify Graph number - must be same as in Report} Crpe1.GraphType.Add(0);

{Section must also be specified when using Add} Crpe1.GraphType.Section := 'PH'; Crpe1.GraphType.Style := ThreeDBars; Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

348

GraphType Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GraphType 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 method is only applied to the GraphType object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the GraphType of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method.

Example

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

Crpe1.GraphType.Clear;

This code clears the GraphType properties for all the Subreports:

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

Crpe1.Subreports[cnt];

Crpe1.GraphType.Clear; end;

GraphType CopyFrom method

Declaration

function CopyFrom(Source: TCrpeGraphType): boolean;

Description

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

VCL Reference

349

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