The requested page is not available for the requested platform. You are viewing the content for Default platform.

Hide Table Cells

  • 3 min to read

You can hide a specific table cell conditionally, for instance, based on a report parameter value.

Right-click the Parameters section in the Field List and select Add Parameter.


In the invoked Add New Parameter dialog, specify the parameter's name and description for Print Preview, and set the type to Boolean.


You can use the following approaches to hide a table cell:

  • Specify an expression for the cell's XRControl.Visible property to define a logical condition for displaying or hiding this cell.

    The image below demonstrates how to provide the visibility expression for the cell bound to the CategoryID field. For a report to display correctly, you should specify the same expression for the cell displaying the field caption in the Page Header.


  • Set the table cell's XRControl.Visible property to false at runtime when a specific condition is met (for example, by handling the report's XRControl.BeforePrint event).

    private void XtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
        if (Convert.ToBoolean(showCatID.Value)) {
            xrTableCell2.Visible = true;
            xrTableCell6.Visible = true;
        else {
            xrTableCell2.Visible = false;
            xrTableCell6.Visible = false;
  • In the cell's XRControl.BeforePrint event handler, set the event argument's Cancel property to true.

    private void xrTableCell2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
        if (!Convert.ToBoolean(showCatID.Value))
            e.Cancel = true;
    private void xrTableCell6_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
        if (!Convert.ToBoolean(showCatID.Value))
            e.Cancel = true;

The XRTable.ProcessHiddenCellMode property allows you to define how to distribute the remaining space between the table's visible cells.


The table below lists the available modes for processing hidden cells and the result in Print Preview.



Cell is visible

The following image illustrates how an original table looks like:



A cell located to the left of the hidden cell is stretched to occupy the available space. If the hidden cell is the first in the row, the next cell is stretched.



A cell located to the right of the hidden cell is stretched to occupy the available space. If the hidden cell is the last in the row, the previous cell is stretched.



All visible cells are resized to equally divide the space that a hidden cell reserved.



All visible cells are resized to proportionally divide the space that a hidden cell reserved based on their weights in the whole table width.



The table width is decreased, and visible cells are shifted to a hidden cell's location without changing their size.



(the default mode)

An empty space remains at a hidden cell's location and other cells are not affected.