ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Working with C1Report > Developing Reports for Desktop Scenarios > Customizable Reports

Customizable Reports

Customizable reports are a variation on Reports Loaded at Run Time. This scenario consists of loading the basic report definitions from a file, then writing code to customize the reports according to user selections.

For example, the following code changes the font used in the Detail section:

      Visual Basic

Imports C1.C1Report

Dim s As Section = c1r.Sections(SectionTypeEnum.Detail)

Dim f As Field

For Each f In s.Fields

  f.Font.Name = "Arial Narrow"

Next

      C#

using C1.C1Report;

Section s = c1r.Sections[SectionTypeEnum.Detail];

foreach (Field f in s.Fields)

  f.Font.Name = "Arial Narrow";

The following code toggles the display of a group by turning its Sort property on or off and setting the Visible property of the Group's Header and Footer sections:

      Visual Basic

Dim bShowGroup As Boolean

bShowGroup = True

With c1r.Groups(0)

  If bShowGroup Then

    .SectionHeader.Visible = True

    .SectionFooter.Visible = True

    .Sort = SortEnum.Ascending

  Else

    .SectionHeader.Visible = False

    .SectionFooter.Visible = False

    .Sort = SortEnum.NoSort

    End If

End With

      C#

bool bShowGroup;

bShowGroup = true;

  if (bShowGroup)

  {

    c1r.Groups[0].SectionHeader.Visible = true;

    c1r.Groups[0].SectionFooter.Visible = true;

    c1r.Groups[0].Sort = SortEnum.Ascending;

  }

  else

  {

    c1r.Groups[0].SectionHeader.Visible = false;

    c1r.Groups[0].SectionFooter.Visible = false;

    c1r.Groups[0].Sort = SortEnum.NoSort;

  }

These samples illustrate just a few ways that you can customize reports. There are infinite possibilities, because the object model offers access to every aspect of the report. (In fact, you can create whole reports entirely with code).


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.