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

Description

The SectionAsCode property can be used to read and write the Section property via Print Engine Section Code numbers. Since the Print Engine Section Codes are numeric, it is easier to apply conditional formatting to certain sections (in a For loop for example) based on mathematical calculations on the Section Code number than it is by parsing out the regular Section Code string (GH1b, etc.).

See also: About Section Names, Volume 1, Chapter 7.

Example

The SectionAsCode property can be used to apply formatting to specific sections based on mathematical calculations or comparisons. The following code checks each section to see if it is a "b" section, such as RHb, PHb, Db, etc., and if it is, the Font Size is changed to 10 point:

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

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

if (Crpe1.SectionFont[cnt].SectionAsCode mod 1000 = 25) then Crpe1.SectionFont[cnt].Size := 10;

end; Crpe1.Execute;

The logic behind the math expression is based on the fact that each sub-section increments the Section Code number by 25 (from 0 to 975 are the possible numbers). So, since 3000 is the general Section Code start number for a Group Header, and is therefore the number to represent GroupHeader 1a, 3025 represents GroupHeader 1b, 3050 represents GroupHeader 1c, etc. Therefore, in order to find the "b" sections we must divide by 1000, and if the remainder is 25, it is a "b" section. This also works for all the other sections that do not have Group options, such as Details, ReportHeader, etc. since dividing by 25 will also return no remainder if the Section Code number is evenly divisible by 1000.

SectionFont Size property

Declaration

property Size: smallint;

Description

The Size property determines how large or small the Font will be. The scale is in points.

VCL Reference

536

Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name and Size for that section:

var

cnt: integer; begin

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

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

{Look for Details area}

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

Crpe1.SectionFont[cnt].Name := 'Times New Roman'; Crpe1.SectionFont[cnt].Size := 10;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFont StrikeThrough property

Declaration

property StrikeThrough: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The StrikeThrough property determines whether the Font should have strike through lines in it. Use cDefault for no change.

VCL Reference

537

Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and StrikeThrough properties for that section:

var

cnt: integer; begin

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

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

{Look for Details area}

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

Crpe1.SectionFont[cnt].Name := 'Times New Roman'; Crpe1.SectionFont[cnt].Size := 10; Crpe1.SectionFont[cnt].StrikeThrough := cTrue;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFont Underlined property

Declaration

property Underlined: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

Description

The Underlined property determines whether the Font should be underlined. Use cDefault for no change.

Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Underlined properties for that section:

var

cnt: integer; begin

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

VCL Reference

538

Crpe1.SectionFont.Retrieve;

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

{Look for Details area}

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

Crpe1.SectionFont[cnt].Name := 'Times New Roman'; Crpe1.SectionFont[cnt].Size := 10; Crpe1.SectionFont[cnt].Underlined := cTrue;

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

SectionFont Weight property

Declaration

property Weight: TCrFontWeight;

Type

TCrFontWeight = (fwDefault, fwThin, fwExtraLight, fwLight, fwNormal, fwMedium, fwSemiBold, fwBold, fwExtraBold, fwHeavy);

Description

The Weight property determines how heavy (thick) or light (thin) the Font will appear. Use fwDefault for no change.

Example

The code below retrieves the SectionFont settings from the Report, then loops through looking for the Details "a" section, and sets the Font Name, Size, and Weight properties for that section:

var

cnt: integer; begin

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

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

{Look for Details area}

if Crpe1.SectionFont[cnt].Section = 'Da' then

VCL Reference

539

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