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

SectionFormat

Declaration

property SectionFormat: TCrpeSectionFormat;

Type

TCrpeSectionFormat = class(TPersistent)

Description

SectionFormat controls how the sections of a Report behave. It is similar to AreaFormat, except that AreaFormat applies to all of the sections of the same type, whereas SectionFormat works on every sub-section individually. Since Crystal Reports 5.0, each section of a Report can be split into sub-sections, for example, Details a, Details b, etc. SectionFormat can be used to control each sub-section.

The Section naming format has been adopted from the Crystal Reports "short" section naming convention, so RHa means ReportHeader a, GH3b means GroupHeader 3b, etc. See About Section Names, Volume 1, Chapter 7, for more information.

If the Retrieve method is used to get the Section information from the Report, the SectionFormat object will be automatically populated with valid Section names, which appear in the Section property.

If the manual Add method is used instead, the programmer will have to specify which section to add to the object.

The Count, Item, and ItemIndex properties can be used to navigate through the different Section items in the SectionFormat object.

The BackgroundColor property can be used to change the color of a Section. It is a Delphi TColor type, and so the Delphi color constants can be used, or the Color value from the ColorDialog.

The FreeFormPlacement property determines whether the fields in a section are snapped to grid or not.

The Suppress property will cause a Section to be hidden so that it is not processed. Drill-down is not possible on a suppressed Section (to Hide a Section so that drill-down is still available, use the AreaFormat property, Hide).

The KeepTogether property will prevent a Section from splitting on a page break. This is not the same as Keep Group Together, which is available via the GroupOptions property, KeepTogether.

The NewPageAfter and NewPageBefore properties determine if a page break will happen after or before a particular Section.

The PrintAtBottomOfPage property will cause the Section to appear at the bottom of the page.

The ResetPageNAfter property will cause the Page Number to be reset after a particular Section.

The SuppressBlankSection property will cause a Section that has no data to be suppressed. If any of the fields in the Section have spaces in them, the Section will not be considered blank.

VCL Reference

93

The UnderlaySection property will cause the Section to be displayed under the next Section, like layering two transparencies on top of each other.

The SectionAsCode property offers the ability to treat the Section name as a Section Code Number, which can be useful for doing mathematical expressions to filter out certain sections.

The SectionType method returns just the first characters of the Section name, so for GH1 (Group Header 1), the SectionType would be GH (Group Header).

Limitations

Main Report - For Page Header (PH) and Page Footer (PF) sections, the following options do not apply (setting them will have no effect on the Report):

¾KeepTogether

¾NewPageAfter

¾NewPageBefore

¾PrintAtBottomOfPage

Subreports - For Report Header b (RHb) and Report Footer b (RFb) sections, the following options do not apply (setting them will have no effect on the Report):

¾KeepTogether

¾NewPageAfter

¾NewPageBefore

¾PrintAtBottomOfPage

SectionFormat Example

The code below retrieves the SectionFormat settings from the Report, then loops through looking for the Details "a" section, and sets various options for that section:

var

cnt: integer; begin

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

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

{Look for Details "a" section}

if Crpe1.SectionFormat[cnt].Section = 'Da' then begin

Crpe1.SectionFormat[cnt].BackgroundColor := clRed; Crpe1.SectionFormat[cnt].FreeFormPlacement := cTrue; Crpe1.SectionFormat[cnt].KeepTogether := cTrue;

Crpe1.SectionFormat[cnt].NewPageAfter := cFalse;

VCL Reference

94

Crpe1.SectionFormat[cnt].NewPageBefore := cFalse; Crpe1.SectionFormat[cnt].PrintAtBottomOfPage := cDefault; Crpe1.SectionFormat[cnt].ResetPageNAfter := cFalse; Crpe1.SectionFormat[cnt].Suppress := cTrue; Crpe1.SectionFormat[cnt].SuppressBlankSection := cTrue; Crpe1.SectionFormat[cnt].UnderlaySection := cDefault;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFormat Properties

SectionFormat BackgroundColor property, Page 546

SectionFormat FreeFormPlacement property, Page 546

SectionFormat Hide property, Page 547

SectionFormat Item property, Page 548

SectionFormat ItemIndex property, Page 549

SectionFormat KeepTogether property, Page 549

SectionFormat NewPageAfter property, Page 550

SectionFormat NewPageBefore property, Page 551

SectionFormat PrintAtBottomOfPage property, Page 552

SectionFormat ResetPageNAfter property, Page 553

SectionFormat Section property, Page 553

SectionFormat Suppress property, Page 555

SectionFormat SuppressBlankSection property, Page 556

SectionFormat UnderlaySection property, Page 556

SectionFormat SectionAsCode property, Page 557

SectionFormat Methods

SectionFormat Add method, Page 558

SectionFormat Clear method, Page 559

SectionFormat CopyFrom method, Page 560

SectionFormat Count property, Page 560

SectionFormat Create method, Page 561

SectionFormat Delete method, Page 561

SectionFormat Destroy method, Page 562

VCL Reference

95

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