Reports for WinForms | ComponentOne
Working with C1Report / Developing Reports for Desktop Scenarios / Customizable Reports
In This Topic
    Customizable Reports
    In This Topic

    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:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    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
    

    To write code in C#

    C#
    Copy Code
    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:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    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
    

    To write code in C#

    C#
    Copy Code
    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).