Edit this page

Column Selection

As of R3 2016 entire columns can be added to RadGridView's selection. This can be done in any of the following ways:

Column selection is only available when SelectionMode is either Multiple or Extended and SelectionUnit is either Cell or Mixed.

Select Columns Through the UI

RadGridView's new CanUserSelectColumns property determines whether users can add a whole column to the current selection. The default value is False, but when set to True, a new RadDropDownButton appears in RadGridView's top right corner. When clicked, a ListBox appears, whose ItemsSource is bound to RadGridView's Columns collection. The user can then check and uncheck columns in order to add and remove them from the current selection.

Column selection behaves differently depending on the SelectionMode - when dealing with Extended selection, if you want to select multiple columns, you need to hold down the Ctrl key.

Example 1: Setting RadGridView's CanUserSelectColumns property

this.radGridView.CanUserSelectColumns = true;
Me.radGridView.CanUserSelectColumns = True

Figure 1: Selecting columns through the UI

Selecting columns through the UI

If you do not want to display the column selection button, you can use RadGridView's ColumnsSelectionButtonVisibility property in order to hide it.

Select Columns Via a Column's IsSelected Property

Columns can also be selected programmatically by setting their IsSelected property.

Bear in mind that this will only work if CanUserSelectColumns is set to True.

Example 1: Setting a column's IsSelected property

this.radGridView.Columns["Name"].IsSelected = true;
Me.radGridView.Columns("Name").IsSelected = True

Using the SelectCellRegion Method

Another way to programmatically select columns is by using the SelectCellRegion method:

Example 1: Selecting a column with the SelectCellRegion method

this.radGridView.SelectCellRegion(new CellRegion(this.radGridView.Columns["Name"].DisplayIndex, 0, 1, this.radGridView.Items.Count));
Me.radGridView.SelectCellRegion(New CellRegion(Me.radGridView.Columns("Name").DisplayIndex, 0, 1, Me.radGridView.Items.Count))

See Also