FlexReport for WinForms
サブセクションの追加
FlexReport のセクション > サブセクションの追加

サブセクションは、レポートの任意のセクションに挿入できる追加セクションです。通常、FlexReport には、詳細、ヘッダー、フッター、ページヘッダー、ページフッター、グループヘッダー、およびグループフッターセクションが含まれます。 You can add as many sub-sections as required in a section. This can be done via the FlexReportDesigner application or through code.

Adding Sub-Sections using FlexReportDesigner

Sub-Sections can be added to any section of a report. By default, the sub-section gets added at the bottom of the currently selected section.

For instance, let's say you want to add a sub-section in the Page Header. This can be easily achieved via the FlexReportDesigner in few steps as described below:

  1. Move the cursor to the section of the report where you want to add the sub-section.
  2. Select the section and right-click to view the context menu. Click the Add SubSection option.

Now, you can observe that a sub-section has got added below the Page Header. Move the cursor to the sub-section to view the tooltip that says it is the first subsection of the Page Header section.

Adding Sub-Sections using Code

You can also add a sub-section in the Page Header section of a report programmatically. To illustrate the addition of a sub-section to an existing section like Page Header, we will be using the QuickStart sample used to create a report definition.

In the code snippet below, we will add a subsection to the Page Header using SubSections property of the SubSectionCollection class, and add fields to this sub-section using Fields property of the SubSection class. We have also added a backcolor to the sub-section, just to highlight it.

C#
コードのコピー
// ヘッダーセクションに 1 つのサブセクションを作成します
SubSection ss = c1FlexReport1.Sections.PageHeader.SubSections.Add();
// 高さを 10 mm に設定します
ss.Height = 10 * 1440 / 25.4;
// サブセクションを強調するために背景色を割り当てます
ss.BackColor = Color.Lime;
// サブセクションにフィールドを追加します
TextField textFieldB = new TextField();
textFieldB.Name = "FldID";
textFieldB.Text.Expression = "EmployeeID";
textFieldB.Left = 0;
textFieldB.Top = 0;
textFieldB.Width = 400;
textFieldB.Height = 300;
ss.Fields.Add(textFieldB);
// サブセクションにフィールドを追加します
TextField textFieldA = new TextField();
textFieldA.Name = "FldFirstName";
textFieldA.Text.Expression = "FirstName";
textFieldA.Left = 500;
textFieldA.Top = 0;
textFieldA.Width = 900;
textFieldA.Height = 300;
ss.Fields.Add(textFieldA);

The snapshot of the resulting output is given below: