All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

XRCrossTabCell.BeforePrint Event

Occurs before a Cross Tab cell is printed in a report document.

Namespace: DevExpress.XtraReports.UI.CrossTab

Assembly: DevExpress.XtraReports.v20.1.dll

Declaration

public event CrossTabCellPrintEventHandler BeforePrint
Public Event BeforePrint As CrossTabCellPrintEventHandler

Event Data

The BeforePrint event's data class is CrossTabCellPrintEventArgs. The following properties provide information specific to this event:

Property Description
GroupColumnIndex Specifies the index of a cell's column within a group.
GroupRowIndex Specifies the index of a cell's row within a group.

Remarks

The BeforePrint event occurs when the report's CreateDocument method is called (internally form other methods or explicitly). This event is raised with other events in the following order:

See Report Events for more information.

Handle this event to change the cell's properties before it is printed. Use the event argument's GroupRowIndex and GroupColumnIndex properties to identify indexes of the current row/column within a group. For instance, check these properties to provide different settings for odd and even rows/columns.

You can also call the XRCrossTabCell.GetCurrentFieldValue method to obtain the current value of the specified data source field. If you do not want to cast the returned object, use the XRCrossTabCell.GetCurrentFieldValue<T> method, which returns a strongly typed object.

NOTE

This event does not have any relation to the actual print process. To manage print settings, handle the PrintingSystemBase.StartPrint event instead.

The BeforePrint is not raised when you export the document to any available format because the export operation does not recreate the report document.

Examples

This example demonstrates how to handle a Cross Tab cell's BeforePrint event and customize the cell's appearance based on its current value and row index.

using System.Drawing;
using DevExpress.XtraReports.UI.CrossTab;
// ...
private void xrCrossTabCell3_BeforePrint(object sender, CrossTabCellPrintEventArgs e) {
    // Obtain the current cell.
    XRCrossTabCell cell = (XRCrossTabCell)sender;

    // Change the cell's foreground color if its value exceeds 3000.
    decimal value = cell.GetCurrentFieldValue<decimal>("Extended Price");
    if (value > 3000)
        cell.ForeColor = Color.Red;
    else cell.ForeColor = Color.Black;

    // Apply different background colors to odd and even rows.
    if (e.GroupRowIndex % 2 == 0)
        cell.BackColor = Color.LightCyan;
    else cell.BackColor = Color.White;
}

See Also