Multiple Row Selection via Built-In Check Column and Selection Binding
- 3 minutes to read
The GridView supports multiple row selection via a built-in Check column. When this feature is enabled, end-users can use checkboxes to toggle the selection state of certain rows, all rows or data group rows.
Note
The BandedGridView and AdvBandedGridView do not support row selection via the built-in Check column.
Demo: Web Style Row Selection module in the XtraGrid MainDemo
Enable Built-In Check Column
To enable row selection via the built-in Check column, set the properties as follows:
- ColumnViewOptionsSelection.MultiSelect to true.
- GridOptionsSelection.MultiSelectMode to GridMultiSelectMode.CheckBoxRowSelect.
gridView1.OptionsSelection.MultiSelect = true
gridView1.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CheckBoxRowSelect
Check Column Specifics
- The Check column is always the first column in the grid.
- Clicking on a cell’s checkbox while pressing the ALT, CTRL or SHIFT key does not toggle this checkbox.
- When the Check column is enabled, you can select rows using common mouse and keyboard shortcuts (see End-user Capabilities.Selecting Rows).
- By default, clicking on a data cell outside the Check column does not clear the current selection. To enable this feature, set the GridOptionsSelection.ResetSelectionClickOutsideCheckboxSelector property to true.
- The GridOptionsSelection.CheckBoxSelectorColumnWidth specifies the column’s width.
Check Box in Column Header
The checkbox in the Check column header allows you to select/deselect all grid rows. Use the GridOptionsSelection.ShowCheckBoxSelectorInColumnHeader property to hide this checkbox.
Check Boxes in Group Rows
Group rows can also contain checkboxes if the GridOptionsSelection.ShowCheckBoxSelectorInGroupRow property value is True. These checkboxes switch the selection states of rows that belong to specific groups.
Sync Selection with Data Source
Specify the GridOptionsSelection.CheckBoxSelectorField property to bind the Check column to a field in the bound data source. When you change a row’s selection state (via the Check column or in code), the grid automatically updates the specified data source field.
Check column bound mode provides the following advantages, in contrast to the default (unbound) mode:
- The ability to filter data by a row’s selection state using the automatic filter row;
- Row selection persists when end-users group and filter data.
Tip
In Check column bound mode, multiple row selection may lead to performance issues due to excessive data source updates. For instance, this may occur when clicking the check box embedded in the Check column’s header for a grid bound to a large data source. Disable the GridOptionsSelection.ShowCheckBoxSelectorInColumnHeader for large data sources, or alternatively, use the Check column in unbound mode.
Note
In Check column bound mode, group rows never display check boxes, regardless of the GridOptionsSelection.ShowCheckBoxSelectorInGroupRow setting.
Checkboxes in Print/Export Documents
The GridOptionsSelection.ShowCheckBoxSelectorInPrintExport property specifies the Check column’s visibility in printed/exported documents.
Methods to Work with Selected Rows
See the Multiple Row and Cell Selection topic to learn about the methods used to select rows in code, retrieve and delete the selected rows, or copy them to the Clipboard.