Xceed Grid for WinForms v4.3 Documentation
The ReportSettings class

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Reporting > The ReportSettings class

The ReportSettings class defines several properties and methods useful for printing and exporting reports, as well as properties that allow the settings of GenerateReportForm to be persistent. The two "Persisted" properties (PersistedSettings and PersistedColumnProperties) and the CustomVariables properties will be discussed here. A ReportSettings object is exposed via the ReportSettings property of the GridControl.

Creating custom variables

The CustomVariables property lets you programmatically define variables for use in the page headers and footers, in the same way as the built-in %TITLE%, %PAGES%, %TOTALPAGES% and %DATETIME% variables. The CustomVariables property is case-insensitive. The following code adds a custom variable:

VB.NET Copy Code
Me.gridControl1.ReportSettings.CustomVariables.Add("DISCLAIMER", _
   "This document is highly confidential and must not be disclosed! All content Copyright " + _
   "2004-2007 Widget Sellers, Inc.")
C# Copy Code

this.gridControl1.ReportSettings.CustomVariables.Add("DISCLAIMER",
      "This document is highly confidential and must not be disclosed! " + "
      "All content Copyright 2004-2007 Widget Sellers, Inc.");

With this variable added, end-users simply need to use %DISCLAIMER% in the Customize Report Style form, rather than typing out the entire disclaimer text. 

The QueryVariableText event of the Report class lets you create dynamic custom variables, whose text can be changed before printing. This event can also be used to modify the text of the built-in variables.

The PersistedSettings property

The PersistedSettings property contains a list of the properties of the ReportSettings class that will be persisted with its associated GridControl. Combined with the PersistedColumnProperties property (see below), this allows all of the settings in the GenerateReportForm to be persistent. By default, all of the settings available in the Generate Report form are persisted with the grid. You can use the Remove method to remove a property you do not wish to persist. In the following code, the PrinterName property is removed:

VB.NET Copy Code
Me.gridControl1.ReportSettings.PersistedSettings.Remove("PrinterName")
C# Copy Code
this.gridControl1.ReportSettings.PersistedSettings.Remove("PrinterName");

You can force settings to be persisted by using the Save method of the ReportSettings class. Settings are saved in an XML-format file:

VB.NET Copy Code
Me.gridControl1.ReportSettings.Save("c:\temp\reportSettings.xml")
C# Copy Code
this.gridControl1.ReportSettings.Save(@"c:\temp\reportSettings.xml");

Settings can retrieved by using the ReportSettings.Load method.

The PersistedColumnProperties property

The PersistedColumnProperties property allows you to persist properties specific to column presentation, namely, what is contained in the Column Settings section of the Generate Report form. By Default, the Visible and Width properties of the columns are persisted. 

Having the settings of the Generate Report form available in two different properties allows you to save some settings globally for all users (such as Title, Landscape, etc.), but other settings on a per-user basis, such as PrinterName, PaperSourceName, etc. 

In order to make persisting other properties useful (which are available in ColumnReportStyle), the end-user must have access to these settings, for example, by modifying the Generate Report form. See Using GenerateReportForm for details.