Show and Hide Columns

  • 2 minutes to read

In Code

To hide a column from the GridControl, set the BaseColumn.Visible property to false. To hide column from the Column Chooser, set the column's ColumnBase.ShowInColumnChooser property to false.

    <dxg:GridColumn FieldName="Name" IsSmart="True"/>
    <dxg:GridColumn FieldName="City" IsSmart="True">
    <dxg:GridColumn FieldName="Visits" IsSmart="True" Visible="False"/>
    <dxg:GridColumn FieldName="Birthday" IsSmart="True" Visible="False" ShowInColumnChooser="False">

You can sort data against hidden columns with the GridSortInfo.SortOrder property:

<dxg:GridColumn FieldName="Visits" IsSmart="True" SortOrder="Ascending" Visible="False"/>

Use the GridControl.Columns property to get all the GridControl's columns (visible and hidden). Use the GridViewBase.VisibleColumns property to get visible columns. You can access individual columns and bands by a name or index.

Column Chooser

The Column Chooser allows end users to hide and show columns from the GridControl at runtime. Refer to the Show and Hide Columns topic for more information.

API Description
DataViewBase.ShowColumnChooser Shows the Column Chooser. After you showed the Column Chooser, the GridControl rises the DataViewBase.ShownColumnChooser event.
DataViewBase.HideColumnChooser Hides the Column Chooser. After you hid the Column Chooser, the GridControl rises the DataViewBase.HiddenColumnChooser event.
DataViewBase.IsColumnChooserVisible Gets or sets whether the Column Chooser is visible.
DataViewBase.ColumnChooserTemplate A template that defines the Column Chooser's presentation.
ColumnBase.ColumnChooserHeaderCaption A caption of the column's header displayed in the Column Chooser.
DataViewBase.ColumnChooserColumns A list of columns displayed in the Column Chooser.
DataViewBase.ColumnChooserColumnDisplayMode The Column Chooser's display mode (ShowAllColumns, ShowHiddenColumnsOnly).
TableView.ShowBandsInCustomizationForm Shows the Bands tab in the Column Chooser (in the ShowHiddenColumnsOnly mode).