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.v20.1.dll

Declaration

public virtual void ClearSelection()
Public Overridable Sub ClearSelection

Remarks

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.

NOTE

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 real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.

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:
                view.SelectAll();
                e.Handled = true;
                break;
            case Keys.N:
                view.ClearSelection();
                e.Handled = true;
                break;
        }
}
See Also