Show and Hide Columns
- 2 minutes to read
In Code
Set the BaseColumn.Visible property to false
to hide a column or a band from the GridControl. To hide a column or a band from the Column Chooser, set the column’s BaseColumn.ShowInColumnChooser property to false
.
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Name" IsSmart="True"/>
<dxg:GridColumn FieldName="City" IsSmart="True">
...
</dxg:GridColumn>
<dxg:GridColumn FieldName="Visits" IsSmart="True" Visible="False"/>
<dxg:GridColumn FieldName="Birthday" IsSmart="True" Visible="False" ShowInColumnChooser="False">
...
</dxg:GridColumn>
</dxg:GridControl.Columns>
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 GridControl columns (visible and hidden). Use the GridViewBase.VisibleColumns property to get visible columns. You can access individual columns and bands by 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 show the Column Chooser, the GridControl raises the DataViewBase.ShownColumnChooser event. |
DataViewBase.HideColumnChooser | Hides the Column Chooser. After you hide the Column Chooser, the GridControl raises 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 | The column header caption 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). |