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

ParamFields Info Send method

Declaration

function Send: boolean;

Description

The Send method sends the Info 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), or when ParamFields.Send is called.

We strongly recommend 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 ParamFields Info settings for the first ParamField are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically for each ParamField in the ParamFields.Send method which is in turn called by the Execute method:

Crpe1.ParamFields[0].Info.Send;

ParamFields Item property

Declaration

property Item[const nIndex: integer]: TCrpeParamFields;

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 ParamFields 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: ParamFields[2] is the same as ParamFields.Item[2].

Item returns a reference to itself, so the ParamFields properties can be used right after the subscript: ParamFields[2].Value := '100';

VCL Reference

455

Example

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

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

{Set ParamFields to the 3rd Parameter field} Crpe1.ParamFields.Item[2];

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

{Set ParamFields to the 3rd Parameter field} Crpe1.ParamFields[2];

ParamFields ItemIndex property

Declaration

property ItemIndex: integer;

Description

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

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

ParamFields Name property

Declaration

property Name: TCrParameterFieldName;

VCL Reference

456

Type

TCrParameterFieldName = string[255];

Description

The Name property is the key property for the ParamFields sub-class. It contains the Name of the Parameter Field. It is a look-up property and therefore cannot be directly written to. If the Retrieve method is used, the Name property is automatically filled when the ParamFields are retrieved and when the ParamFields object is pointed to one of the retrieved items. To write to it indirectly, use the Add method.

When the Name property is changed, all of the properties of the ParamFields object are updated to look at that particular ParamField.

Note that it is also possible, and often easier, to navigate through the various ParamFields items by using the default Item property, or the ItemIndex property.

Example

This example illustrates the use of the Name property to navigate through the ParamFields object:

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

{Set ParamFields object to item 'FirstParam' name} Crpe1.ParamFields.Name := 'FirstParam';

{Set ParamFields item Value} Crpe1.ParamFields.Value := 'CA'; Crpe1.Output := toWindow; Crpe1.Execute;

Note that since there is an internal index in the ParamFields object (and most of the other Crystal VCL subclass objects), it is not necessary to specify a subscript (i.e. ParamFields[0].Value) every time a property is set. Once the sub-class object is pointing to a certain item, the other properties apply to that item, whether the subscript is specified or not.

ParamFields NeedsCurrentValue property

Declaration

property NeedsCurrentValue: boolean;

Description

NeedsCurrentValue is a read-only property that will only have a meaningful value if the Retrieve method is used to fetch the ParamField items from the Report. It indicates whether a ParamField item requires a value or not. Any ParamFields that are created as a result of a Subreport link, or that are not used in the Report, will return False for NeedsCurrentValue. These ParamFields do not require values, and will not prompt for values when a Report is run.

VCL Reference

457

Example

This example checks the NeedsCurrentValue property before assigning a ParamField Value:

var

cnt: integer; begin

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

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

if Crpe1.ParamFields[cnt].NeedsCurrentValue = True then Crpe1.ParamFields[cnt].Value := 'CA';

end;

Crpe1.Output := toWindow;

&USH ([HFXWH end;

ParamFields ParamSource property

Declaration

property ParamSource: TCrParamFieldSource;

Type

TCrParamFieldSource = (psReport, psStoredProc, psQuery);

Description

The ParamSource property is a read-only property that reveals the source of the Parameter. With the release of SCR 7, the ParamFields class now handles Crystal Reports Parameter Fields, Stored Procedure Parameters, and Crystal Query Parameter Fields, and this property provides a way to distinguish between them. The Retrieve method must be called before this property will have a meaningful value.

Example

This example feeds all the Stored Procedure Parameter names to a ListBox:

var

cnt: integer; begin

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

VCL Reference

458

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