Xceed Grid for WinForms v4.3 Documentation
Ambientness and reports

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Reporting > Ambientness and reports

Ambientness is a characteristic of most of the properties that represent the appearance of elements in the grid. A property is ambient when its value has not been explicitly set and is therefore retrieved from its parent. The property from which a property inherits its value is called its ambient parent. 

The report style properties are ambient and will inherit a value from their ambient parent if their own property is not explicitly set. For example, if you explicitly set the ReportStyle.HorizontalAlignment of a cell, the ReportStyle.HorizontalAlignment of its parent will be ignored. If however you do not explicitly set a cell's ReportStyle.HorizontalAlignment property, it will inherit the value from its parent.

Ambientness: ReportStyle properties and ReportStyleSheet properties

When the ReportStyle property of a grid element (or any property of its parent’s report style) is explicitly set, that property overrides the corresponding property in a ReportStyleSheet. The ReportStyle properties are therefore the first properties in a hierarchy of report styles. Furthermore, once a ReportStyle property has been explicitly set, attempting to set the corresponding property in a ReportStyleSheet will have no effect until a “Reset” method is called on the appropriate grid control element’s ReportStyle. Consider the following code:

VB.NET
Copy Code
Me.gridControl1.ReportStyle.BackColor = Color.Red

Dim report As New Report( Me.gridControl1 )

report.ReportStyleSheet.Grid.BackColor = Color.Green

report.PrintPreview()
C#
Copy Code
this.gridControl1.ReportStyle.BackColor = Color.Red;

Report report = new Report( this.gridControl1 );

report.ReportStyleSheet.Grid.BackColor = Color.Green;

report.PrintPreview();

Because the grid control’s ReportStyle is explicitly set to Color.Red, the grid in the report is red in the print preview, even though ReportStyleSheet.BackColor is set to Color.Green just before the call to PrintPreview. Resetting the grid element lets this color assert itself:

VB.NET
Copy Code
Me.gridControl1.ReportStyle.ResetBackColor()

report.PrintPreview()
C#
Copy Code
this.gridControl1.ReportStyle.ResetBackColor();

report.PrintPreview();

If no ReportStyle properties are set, the properties in a ReportStyleSheet object are used next. The ambientness hierarchy for styles is as follows:

  1. Preference is first given to the report style properties of specific types (ColumnManagerRow, GroupManagerRow, DataRow). The hierarchy of detail grids is followed up to the main grid.

  2. Next, the styles are considered by section (for example, HeaderRow or FooterRow). The hierarchy of detail grids is followed up to the main grid.

  3. Finally, the styles of the "bodies" (Group or Grid) are considered. The hierarchy of detail grids is followed up to the main grid.

It should be noted that the GridElement properties that control the appearance of grid elements (for example, gridControl1.DataRows[0].BackColor holds the color of the first data row of gridControl1), have no effect on the ReportStyle properties and the properties within a ReportStyleSheet object. Consequently, when producing a report, the properties set on the grid elements themselves won't be considered: only ReportStyleSheet and ReportStyle properties will be used. 

Note: If you provide GenerateReportForm for your end-users, you should avoid using the ReportStyle properties of the various grid elements, as the latter always have precedence over the settings in the form. If you modify the values of the ReportStyle properties, it may not be clear to end-users why the report style settings they choose in the form are not being applied.

Non-ambient properties

The following properties are not ambient:

For more details on the concept of ambientness as it applies to the grid elements, see Ambient properties.