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

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

for cnt := 0 to (Crpe1.GroupSortFields.Count - 1) do Crpe1.GroupSortFields[cnt].Direction := sdDescending;

end;

GroupSortFields Create method

Declaration

constructor Create;

Description

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

GroupSortFields Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the GroupSortFields object. The "nIndex" parameter represents the number of the item in the GroupSortFields object, which may not be the same as the GroupSortFields Number value.

NOTE: Delete will not remove the GroupSortField from the Report, it will just remove it from the Crystal VCL. Set the DeleteGSF property to remove a GroupSortField from the Report.

VCL Reference

395

Example

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

Crpe1.ReportName := 'C:\Company.rpt'; {Specify a GroupSortFields Number} Crpe1.GroupSortFields.Add(0);

Crpe1.GroupSortFields.Field := 'Sum({company.SALES},{company.STATE})'; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.GroupSortFields.Delete(0);

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

GroupSortFields Retrieve method

Declaration

function Retrieve: boolean;

Description

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

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

VCL Reference

396

Example

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

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

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

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

end;

GroupSortFields Send method

Declaration

function Send: boolean;

Description

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

Crpe1.GroupSortFields.Send;

VCL Reference

397

LogOnInfo Properties

LogOnInfo DatabaseName property

Declaration

property DatabaseName: string;

Description

This property contains the name of the Database being connected to. Most SQL Servers require this parameter (Oracle is usually an exception to the rule).

Example

This example shows how to retrieve LogOn information and then set it for each item:

var

cnt: integer; begin

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

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

Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise'; Crpe1.LogOnInfo[cnt].UserID := 'Kirk'; Crpe1.LogOnInfo[cnt].Password := 'captain'; Crpe1.LogOnInfo[cnt].DatabaseName := 'stats';

end; Crpe1.Execute;

end;

LogOnInfo DescriptiveName property

Declaration

property DescriptiveName: string;

Description

DescriptiveName is a runtime, read-only property that contains descriptive information about the Table that the LogOnInfo item applies to. It will only have a value if the Retrieve method was used. The DLLName, and TableType properties also provide more details that describe the Table.

VCL Reference

398

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