Skip to main content

ColumnView.ClearSelection() Method

Unselects any selected rows in the current View when multiple row selection is in effect.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid


public virtual void ClearSelection()


The ClearSelection method unselects all the selected rows (cards) when multiple row selection is in effect (the ColumnViewOptionsSelection.MultiSelect property is set to true). If multiple row selection is not in effect, this method does nothing. To unselect an individual row (card), call the View’s ColumnView.UnselectRow method.

After you call the ClearSelection method, the ColumnView.GetSelectedRows method returns null (Nothing in Visual Basic).

Refer to the Multiple Row and Cell Selection topic for general information about row (card) selections.


Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the ClearSelection member must not be invoked for these Views. The ClearSelection member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The code sample below illustrates how to select all grid cells when users press CTRL+A, and how to clear the selection when users press CTRL+N.

gridView1.OptionsSelection.MultiSelect = true;
gridView1.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect;
gridView1.KeyDown += GridView1_KeyDown;

private void GridView1_KeyDown(object sender, KeyEventArgs e)
    GridView view = sender as GridView;
    if (e.Control)
        switch (e.KeyCode)
            case Keys.A:
                e.Handled = true;
            case Keys.N:
                e.Handled = true;
See Also