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

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.Tables.Retrieve;

for cnt := 0 to (Crpe1.Tables.Count - 1) do Crpe1.Tables[cnt].Name := 'NewTable.dbf';

end;

Tables Create method

Declaration

constructor Create;

Description

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

Table Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the Tables object. The "nIndex" parameter represents the number of the item in the Tables object, which may not be the same as the actual Table Number.

NOTE: Delete will not remove the Table from the Report, it will just remove it from the Crystal VCL.

VCL Reference

678

Example

The following code uses the Add method to set the values for the first table in a Report, and then, after running the Report, deletes the Table item from the VCL. This is not normally necessary, though, as Tables would automatically be cleared when the ReportName changes:

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

Crpe1.Tables.Add(0);

Crpe1.Tables[0].Name := 'Address.dbf';

Crpe1.Tables[0].Path := 'C:\Temp\Tables\';

Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.Tables.Delete(0);

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

Tables Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Tables information from the Report and adds one item to the Tables object for each Table in the Report. If Tables information was not found, the call returns False. Be aware that calling Retrieve will first cause the Tables object to be cleared, so any current information stored in it will be removed.

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

VCL Reference

679

Example

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

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

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

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

end;

Tables Send method

Declaration

function Send: boolean;

Description

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

Crpe1.Tables.Send;

VCL Reference

680

Version Properties

Version DLL property

Declaration

property DLL: string;

Description

The DLL property is a read-only property that contains the DLL version number of the CRPE32.DLL which is currently open.

The DLL property can be used whenever you build functionality into a Report that may not be available in earlier versions of the Crystal Report Engine and you need to verify the version number first. This property can also be a handy safeguard for users who have more than one version of the Crystal Report Engine with the older version earlier in the path than the new version.

NOTE: There is some internal protection built into the VCL which will prevent operation if a CRPE32.DLL earlier than 5.x.x.108 attempts to load.

The SummaryInfo object, the WindowEvents, the WindowCursor object, and most of the WindowButtonBar options (except for Visible), will only work with Crystal Reports 6.0, and the ParamFields object requires the last maintenance release of 5.0: 5.0.x.108.

Example

The following example checks to see if the version of the CRPE32.DLL is greater than 5. If it is, the WindowButtonBar buttons can be made visible/invisible.

if StrToInt(Crpe1.Version.DLL[1]) > 5 then Crpe1.WindowButtonBar.AllowDrillDown := True;

Version Engine property

Declaration

property Engine: string;

Description

The Engine property is a read-only property that contains the Engine version number of the CRPE32.DLL which is currently open.

VCL Reference

681

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