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

SessionInfo Delete method

Declaration

procedure Delete(nIndex: integer);

Description

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

Example

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

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

{Specify Table Number - must be same as in Report} Crpe1.SessionInfo.Add(0);

Crpe1.SessionInfo.UserID := 'Bond'; Crpe1.SessionInfo.UserPassword := '007'; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.SessionInfo.Delete(0);

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

SessionInfo Retrieve method

Declaration

function Retrieve: boolean;

VCL Reference

610

Description

The Retrieve method obtains the SessionInfo information from the Report and stores it in the SessionInfo object. If no SessionInfo information was found, the call returns False. Be aware that calling Retrieve will first cause the SessionInfo object to be cleared, so any current information stored in it will be removed.

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

Example

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

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

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

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

end;

SessionInfo Send method

Declaration

function Send: bololean;

Description

The Send method sends the SessionInfo 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.

VCL Reference

611

Example

In this example, the SessionInfo settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.SessionInfo.Send;

SortFields Properties

SortFields DeleteSF property

Declaration

property DeleteSF: boolean;

Description

The DeleteSF property can be used to remove a SortField from a Report. The SortField is not actually removed from the Report until the Execute method is called. After Execute is called, the SortField is also removed from the VCL.

NOTE: DeleteSF is not the same as Delete. Delete removes a SortField item from the SortFields object, not from the Report.

Example

This example will remove the second SortField from a Report when that Report is run:

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

Crpe1.SortFields.Retrieve;

Crpe1.SortFields[1].DeleteSF := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

SortFields Direction property

Declaration

property Direction: TCrSortDirection;

Type

TCrSortDirection = (sdDescending, sdAscending, sdDefault);

VCL Reference

612

Description

The Direction property determines the Sort Order, which can either be sdDescending (9..0, Z..A), sdAscending (0..9, A..Z), or sdDefault (no change).

Example

This example changes the Sort Order of the first SortField to ascending:

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

Crpe1.SortFields.Retrieve;

Crpe1.SortFields[0].Direction := sdAscending;

Crpe1.Output := toWindow;

Crpe1.Execute;

SortFields Field property

Declaration

property Field: string;

Description

The Field property specifies the field that will control sorting. Sort fields can be database fields or formula fields.

Enclose field names in braces: {company.STATE}.

If a formula field is specified, use the @ sign before the formula name: {@FormulaName}.

Example

This example changes the second SortField to be sorted on a formula field called FormulaOne:

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

Crpe1.SortFields.Retrieve;

Crpe1.SortFields[1].Field := '{@FormulaOne}';

Crpe1.Output := toWindow;

Crpe1.Execute;

SortFields Item property

Declaration

property Item[const nIndex: integer]: TCrpeSortFields;

VCL Reference

613

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