THIS EXAMPLE IS OBSOLETE SINCE THE REQUIRED FUNCTIONALITY IS SUPPORTED OUT OF THE BOX.
Starting with version 13.2, GridView provides a built-in checkbox column for multiple row selection. So, to enable this type of multiple row selection in newer versions, it is sufficient to enable the GridViewOptionsSelection.MultiSelect option and then set the GridView.OptionsSelection.MultiSelectModeproperty to the GridMultiSelectMode.CheckBoxRowSelectvalue. Take a look at the How to use an unbound check box column to select grid rows example for sample code.
Starting with version 18.1, in multiple row selection mode, you can sync row selected states with a Boolean field in the bound data source. The selection binding mode ensures that row selection persists whenever you filter or group grid data. Refer to the Multiple Row Selection via Built-In Check Column and Selection Binding help article for more information.
If the built-in CheckBox column does not suit you, we will be happy to find the most appropriate solution for you if you describe your real-life scenario. Just click here to submit a ticket to our Support Center.
FOR EARLIER VERSIONS:
This example demonstrates how to add a check column to allow web-style multiple row selection. End-users can select/deselect rows, group rows or select/deselect all rows by clicking the column header. Changing a check box value does not initiate row editing.
All code related to selection resides in the GridCheckMarksSelection helper class. So, to implement this functionality in your application, you can simply add this class to your project and then create a new GridCheckMarksSelection instance.
Please note if you use the AppearanceEvenRow and AppearanceOddRow styles, by default they have a higher priority than the RowStyle event used for the selection in this example. To avoid drawing incorrect selected rows, enable the HighPriority option.
The GridCheckMarksSelection class also provides different ~Select methods which allow selecting data and group rows in code. To obtain selected rows, you can use the SelectedCount property and GetSelectedRow method.