XRTableCell Class

XRTableCell Class

A single Cell in an XRTable's Row.


Assembly: DevExpress.XtraReports.v19.2.dll


public class XRTableCell :


Use XRTableCell objects to place text or other controls in a table. A table cell behaves like an ordinary label control, and displays text from the XRControl.Text property. If an XRTableCell object contains other controls, it cannot display the text.

You can use the cell's XRControl.Controls property to access the contained controls collection. Use the XRTableCell.Row property to access the cell's row.


When you create large tables in code, set the XRTableCell.Weight property to 1 for all table cells - to improve report generator performance.

See Create a Table Report for more information.

#Markup Text

Use markup in table cells to change the text appearance. This behavior is in effect when the AllowMarkupText property is set to true. Refer to AllowMarkupText for more information.


The code sample below illustrates how to create an XRTable at runtime.


Online ExampleRuntime table creation best practices (iterative approach)

using DevExpress.XtraReports.UI;
// ...

// Create a new report and assign a data source to it.
XtraReport report = new XtraReport();
report.DataSource = ds;
report.DataMember = "queryProducts";

// Create a detail band and add it to the report.
DetailBand detailBand = new DetailBand();

// Create a table and add it to the detail band.
XRTable table = new XRTable();

// Create a row with the product name and product price cells.
XRTableRow row = new XRTableRow();
XRTableCell productName = new XRTableCell();
XRTableCell productPrice = new XRTableCell();

// Bind table cells to data fields.
productName.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[ProductName]"));
productPrice.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[UnitPrice]"));













XRTableCell Members

Create a Table Report

DevExpress.XtraReports.UI Namespace

XRLabel.SummaryCalculated Event

Occurs when the automatic summary value of a label has been calculated.


Assembly: DevExpress.XtraReports.v19.2.dll


public event TextFormatEventHandler SummaryCalculated

#Event Data

The SummaryCalculated event handler receives an argument of the TextFormatEventArgs type. The following properties provide information specific to this event.

FormatGets the formatting string applied to the summary's text.
TextGets or sets the text representation of the summary TextFormatEventArgs.Value with the string formatting applied.
ValueGets the value which is automatically calculated as the label's summary.


Use this event to obtain a summary value which is automatically calculated for a label control. This value can be accessed via the TextFormatEventArgs.Value property.

Note: This event is useful when a grand total needs to be calculated for all the detail reports in a master report, as this value can't be calculated automatically in XtraReports.


This example demonstrates how to use the XRLabel.SummaryCalculated event for a label control. In this example, the report's dataset contains two related tables. The Categories table is bound to the main report, and the Products table is used as the DetailReport's data source, which gives a list of products by categories.

The detail report calculates the sum of the UnitPrice column for each product. This summary is calculated automatically. The grand total of the UnitPrice summaries must be displayed in the main report. You have to write your own code to calculate this kind of summary. It cannot be calculated automatically, because the UnitPrice column does not belong to the main report's data source.

You should handle the SummaryCalculated event of summary labels in your detail report. Please note that when the BeforePrint event is fired, a summary value has not yet been calculated; you should use SummaryCalculated to obtain a calculated summary value. The summaries of individual detail reports are incremented in a global variable (GrandTotals), which is then printed in the main report's footer.

using System.Drawing.Printing;
using DevExpress.XtraReports.UI;
// ...

// Grand total value.
double GrandTotals = 0;

// Add the summary value to the grand total.
private void lbUnitPriceTotal_SummaryCalculated(object sender, TextFormatEventArgs e) {
   if(e.Value != null)
      GrandTotals += Convert.ToDouble(e.Value);

// Set the grand total value to the label's text.
private void lbUnitPriceGrandTotal_BeforePrint(object sender, PrintEventArgs e) {
   ((XRLabel)sender).Text = GrandTotals.ToString();

 Sum content of an XRTableCell column

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页