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

Returns

TRUE if the Selection Formula is good.

FALSE if the Selection Formula has an error.

Example

The following example retrieves the current Selection Formula from the Report and adds an OR condition. It then sends the Formula back in, checking it for proper syntax:

Crpe1.ReportName := 'C:\Company.rpt'; {Retrieve the Selection} Crpe1.Selection.Retrieve;

{Add an OR condition}

Crpe1.Selection.Formula.Add(' OR {company.STATE} = "WA"'); {Replace the Selection in the Report with the new one} Crpe1.Selection.Replace := True;

{Check the Selection before running Report} if Crpe1.Selection.Check then

begin

Crpe1.Output := toWindow; Crpe1.Execute;

end;

Selection Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the Selection object. It clears the Formula property and sets the Replace property to True. 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 Selection object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the Selection of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method.

Example

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

Crpe1.Selection.Clear;

VCL Reference

598

This code clears the Selection for all the Subreports:

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

Crpe1.Subreports[cnt];

Crpe1.Selection.Clear; end;

Selection CopyFrom method

Declaration

function CopyFrom(Source: TCrpeSelectionFormula): boolean;

Description

The CopyFrom method copies the Selection property values from another TCrpeSelectionFormula 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 Selection property values to a temporary TCrpeSelectionFormula object:

var

tempSelection : TCrpeSelectionFormula; begin

tempSelection := TCrpeSelectionFormula.Create; tempSelection.CopyFrom(Crpe1.Selection); {...later, when finished with the temp object...} tempSelection.Free;

end;

Selection Create method

Declaration

constructor Create;

Description

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

VCL Reference

599

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

Selection Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Selection Formula from the Report and stores it in the Formula property of the Selection object. If successful, the call returns True. Be aware that calling Retrieve will first cause the Selection object to be cleared, so any current information stored in it will be removed.

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

Example

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

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

Crpe1.Selection.Retrieve;

VCL Reference

600

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

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

end;

Selection Send method

Declaration

function Send: boolean;

Description

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

Crpe1.Selection.Send;

VCL Reference

601

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