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

Example

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

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Tables.Retrieve;

{Set Tables object to the 3rd item} Crpe1.Tables.Item[2]; Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Tables.Retrieve;

{Set Tables object to the 3rd item} Crpe1.Tables[2];

Tables ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Tables item number, or set the Tables 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 (Tables[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 Tables object is pointing to the first Table:

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

Tables Name property

Declaration

property Name: string;

VCL Reference

670

Description

The Name property is the table name of the current Table, without the path. Note that the length of the Path plus the Name should not exceed 256 characters (Print Engine limit).

Example

The following example shows how to change the name of a Table:

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 := 'MyNewName.dbf';

end;

Tables Number property

Declaration

property Number: TCrTableNumber;

Type

TCrTableNumber = integer;

Description

The Number property contains the number of the Table in the Report. It uses a zero-based numbering scheme, so the first Table in a Report is number 0. The Number property is the key lookup property for the Tables object and therefore cannot be changed by direct assignment. For example:

Crpe1.Tables.Number := 2;

will cause the Tables object to look up and move to the second table in the Report. It will not overwrite the current Table with a new Table number.

Example

This example demonstrates the use of the Number property to point to a specific Table:

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

{Go to Table number 2} Crpe1.Tables.Number := 2; {Change the Path for that Table}

Crpe1.Tables.Path := 'C:\NewPath\'; Crpe1.Execute;

VCL Reference

671

Tables Password property

Declaration

property Password: string;

Description

The Password property applies to Paradox password-protected tables. For MS Access password-protected Tables, use the SessionInfo object instead of the Password property of the Tables object.

Example

The code below shows how to use the Password property of the Tables object:

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

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Password := 'SwornToSecrecy';

Crpe1.Execute;

Tables Path property

Declaration

property Path: string;

Description

The Path property is the path of the current Table. If the current table is:

'c:\mydir\table1.dbf'

the Path would be:

'c:\mydir\'

A BDE Alias can also be passed to this property to assign the Table a new path:

Crpe1.Tables.Path := ':MyAlias:';

The Propagate property causes the Path of the first Table to be used for all the Tables in the main Report and all Subreports as well. If Propagate is set to True on a Tables object that belongs to a Subreport, then only the Tables of that Subreport will use the same path as the first Table of the main Report.

Note that Retrieve or Add have to be called first to fill the Tables object with Table items.

The length of the Path plus the Name should not exceed 256 characters (Print Engine limit).

VCL Reference

672

Example

The following code changes the Path of the second Table:

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

Crpe1.Tables.Retrieve;

Crpe1.Tables[1].Path := 'c:\MyNewDir\';

Crpe1.Execute;

The following code changes the Path of the first Table to a BDE Alias called 'MyAlias':

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

Crpe1.Tables.Retrieve;

Crpe1.Tables[0].Path := ':MyAlias:';

Crpe1.Execute;

The following code changes the Path of the first Table and causes the change to be used for all the Tables in the main Report and any Subreports:

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

Crpe1.Tables.Retrieve;

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

Crpe1.Tables.Propagate := True;

Crpe1.Execute;

The following code loops through all Tables in the first Subreport and changes the paths:

Crpe1.ReportName := 'C:\Report1.rpt'; Crpe1.Subreports.Retrieve; Crpe1.Subreports[1]; Crpe1.Tables.Retrieve;

for cnt := 0 to (Crpe1.Tables.Count - 1) do Crpe1.Tables[cnt].Path := 'c:\MyNewDir\';

Tables Propagate property

Declaration

property Propagate: boolean;

Description

In the previous versions of the Crystal VCL, there was a property called "DatafilesLocation" which allowed the programmer to pass in a directory path that would be used for all the Tables in the Report, including any Subreports. This functionality has been included in the Tables object by the inclusion of the Propagate property.

VCL Reference

673

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