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.v24.2.dll

Declaration

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the ClearSelection() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also