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

ParamFields CopyFrom method

Declaration

function CopyFrom(Source: TCrpeParamFields): boolean;

Description

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

Example

The following example copies all the ParamFields property values to a temporary TCrpeParamFields object:

var

tempParamFields : TCrpeParamFields; begin

tempParamFields := TCrpeParamFields.Create; tempParamFields.CopyFrom(Crpe1.ParamFields); {...later, when finished with the temp object...} tempParamFields.Free;

end;

ParamFields Count method

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the ParamFields object. It is handy for setting up loops to make similar changes to each item.

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

for cnt := 0 to (Crpe1.ParamFields.Count - 1) do Crpe1.ParamFields[cnt].Value := 'CA';

end;

VCL Reference

479

ParamFields Create method

Declaration

constructor Create;

Description

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

ParamFields Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the ParamFields object. The "nIndex" parameter represents the number of the item in the ParamFields object.

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

Example

The Delete method can be used to manually remove an item from the ParamFields object:

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

{Specify Parameter Name - must be same as in Report} Crpe1.ParamFields.Add('Parameter1'); Crpe1.ParamFields.Value := 'CA';

Crpe1.Output := toWindow; Crpe1.Execute; Crpe1.ParamFields.Delete(0);

ParamFields Destroy method

Declaration

destructor Destroy; override;

VCL Reference

480

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.

ParamFields IndexOf method

Declaration

function IndexOf(ParameterName: TCrParamFieldName): integer;

Type

TCrParamFieldName = string[255];

Description

The IndexOf method takes a Parameter name and returns the index position of the Parameter item in the current ParamFields object.

After the Retrieve method has been called, the ParamFields object contains one item for each ParamField in the Report. The IndexOf method can be used to determine if a given Parameter Name actually exists in the ParamFields object before trying to access it.

Example

The following code illustrates the use of the IndexOf method to locate a specific ParamField item by it's name:

var

nItem: integer; begin

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

{Find "Param1"}

nItem := Crpe1.ParamFields.IndexOf('Param1'); {If it exists...}

if nItem > -1 then begin

with Crpe1.ParamFields[nItem] do begin

Value := 'CA';

VCL Reference

481

ShowDialog := False; end;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

ParamFields Retrieve method

Declaration

function Retrieve: boolean;

Description

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

Retrieving from the Main Report

ParamFields are treated slightly differently by the Print Engine than most of the other properties. Calling Retrieve for the main Report will return all the ParamFields from the main Report, as well as all the ParamFields from any Subreports. This is because Parameter fields are considered in a certain sense to be part of the main Report, since refreshing the main Report in Crystal Reports will cause the Parameter prompt dialog to display all of the Parameters that require values, whether they are located in the main Report, or in a Subreport.

When retrieving ParamFields for a main Report, any Parameters in a Subreport, that are linked to the main Report, will still be retrieved, but the NeedsCurrentValue property will read False, which means that these Parameter fields do not require values to be set in code, since they will obtain their values from the link to the main Report, when the Report is run.

Retrieving from a Subreport

In most cases, you will want to work with the Parameters as returned in the main Report ParamFields object. However, if you are going to be running Subreports separate from the main Report (see SubExecute), the ParamFields should be retrieved for that Subreport specifically. In other words, the Subreports object should be pointing to the Subreport that is going to be run, before Paramfields.Retrieve is called. This will cause the ParamFields object for that Subreport to be filled with information on the Parameter fields that apply specifically to that Subreport. In such a case, any Parameter fields that are linked to the main Report will appear as unlinked, since they are expecting a value, and will not be getting the value from the main Report when the Subreport is run as stand-alone.

VCL Reference

482

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