Column Selection in RadGridView
Environment
Product Version | Product | Author |
---|---|---|
2019.1.219 | RadGridView for WinForms | Desislava Yordanova |
Description
This article demonstrates how to achieve column selection in RadGridView. For this purpose, it is necessary to keep the Shift
key pressed and click the column's header. As a result all cells, belonging to this column, will be selected.
Solution
Create a derivative of the BaseGridBehavior class. Override its OnMouseDown method where, if the Shift
key is pressed and the header cell element is clicked, you should iterate all rows and select programmatically the cells belonging to the clicked column.
When selecting multiple cells in RadGridView note that the selection should be wrapped in a MasterTemplate.SelectedCells.BeginUpdate - MasterTemplate.SelectedCells.EndUpdate block. Thus, the refresh operation will be done only once at the end of the operation but not with each selected cell.