Skip to main content

Hide Table Cells

  • 3 minutes to read

This help topic describes how you can hide a table cell conditionally, based on the report parameter value.


Start with a Table report bound to the Products table of the Sample Northwind Database.

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


In the invoked Add New Parameter dialog, specify the name (showCatID) and description (Show Category ID), and set the type to Boolean:


Methods to Hide a Cell

You can use the following methods to hide a table cell.

Specify an Expression for the Visible Property

Specify an expression for the cell’s Visible property to define a logical condition to display or hide that cell.

In this example, the showCatID report parameter determines whether the cell bound to the CategoryID field is displayed. The expression bound to the Visible property is as follows:



You should also specify the same expression for the Visibility property of the Category ID cell in the header table.

Handle the XtraReport.BeforePrint Event

Handle the report’s BeforePrint event to set the table cell’s Visible property to False when a certain condition is met.

private void XtraReport1_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    if (Convert.ToBoolean(showCatID.Value)) {
        xrTableCell2.Visible = true;
        xrTableCell6.Visible = true;
    else {
        xrTableCell2.Visible = false;
        xrTableCell6.Visible = false;

Handle the XRTableCell.BeforePrint Event

Set the event argument’s Cancel property to True in the cell’s BeforePrint event handler:

private void xrTableCell2_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    if (!Convert.ToBoolean(showCatID.Value))
        e.Cancel = true;

private void xrTableCell6_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    if (!Convert.ToBoolean(showCatID.Value))
        e.Cancel = true;

How to Fill the Gap Caused by a Hidden Cell

Use the ProcessHiddenCellMode property to define how to distribute the remaining space between visible table cells.


The image below shows the original table:


The following processing modes are available:


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 previously occupied before it was hidden.



All visible cells are resized to proportionally divide the space that a hidden cell previously occupied based on their weights relative to the entire 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.


Preview the Result

The resulting report appears as follows:

Hide Table Cells - Resulting Report