Selection Events
There are a number of events relevant to the selection in the RadGridView control. The sequence of the events depends on the SelectionUnit property:
- FullRow: The sequence of events is as follows— CurrentCellInfoChanged -> SelectionChanging -> SelectedCellsChanging -> SelectedCellsChanged -> SelectionChanged .
- Cell: The sequence of events is as follows— CurrentCellInfoChanged -> SelectedCellsChanging -> SelectedCellsChanged.
- Mixed: The sequence of events depends on whether a row or a cell was selected.
The events are fired by RadGridView each time there is a modification of the SelectedItems / SelectedCells collection, regardless of the way it happened (by user input or programmatically).
SelectionChanging
It is fired once a selection is about to be performed and a change in the SelectedItems collection is to be executed. This is the case when a row is to be selected or un-selected and the SelectionUnit is FullRow or Mixed.
Subscribing to the SelectionChanging event
private void SelectionChanging(object sender, SelectionChangingEventArgs e)
{
}
Private Sub SelectionChanging(sender As Object, e As SelectionChangingEventArgs)
End Sub
SelectionChangingEventArgs exposes the following specific properties:
- AddedItems—A collection of the item(s) that has/have been added to the selection.
- RemovedItems—A collection of the item(s) that has/have been removed from the selection.
- IsCancelable—Gets a value that indicates whether the event is cancelable.
- Cancel—A boolean property that cancels the selection.
SelectionChanged
Fires each time there is a change in the SelectedItems collection. This happens when a row has been selected or un-selected and the SelectionUnit is FullRow or Mixed.
Subscribing to the SelectionChanged event
private void SelectionChanged(object sender, SelectionChangeEventArgs e)
{
}
Private Sub SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangeEventArgs)
End Sub
The SelectionChangeEventArgs class exposes the following specific properties:
- AddedItems—A collection of the items that have been added to the selection.
- RemovedItems—A collection of the items that have been removed from the selection.
CurrentCellInfoChanged
This event is raised when a cell is selected. It fires before the SelectionChanged event.
Subscribing to the CurrentCellInfoChanged event
private void CurrentCellInfoChanged(object sender, GridViewCurrentCellInfoChangedEventArgs e)
{
}
Private Sub CurrentCellInfoChanged(ByVal sender As Object, ByVal e As GridViewCurrentCellInfoChangedEventArgs)
End Sub
The GridViewCurrentCellInfoChangedEventArgs class exposes the following specific properties:
- NewCellInfo—The new cell info.
- OldCellInfo—The old cell info.
SelectedCellsChanging
This event is fired when a change in the SelectedCells collection is about to be performed. This happens when a cell is to be selected or un-selected when the SelectionUnit is Cell or Mixed.
Subscribing to the SelectedCellsChanging event
private void SelectedCellsChanging(object sender, GridViewSelectedCellsChangingEventArgs e)
{
}
Private Sub SelectedCellsChanging(sender As Object, e As GridViewSelectedCellsChangingEventArgs)
End Sub
The GridViewSelectedCellsChangingEventArgs class exposes the following specific properties:
- AddedCells—A collection of the cells that have been added to the selection.
- RemovedCells—A collection of the cells that have been removed from the selection.
- IsCancelable—Gets a value that indicates whether the event is cancelable.
- Cancel—A boolean property that cancels the cell selection.
SelectedCellsChanged
Fires each time there is change in the SelectedCells collection. This happens when a cell has been selected or un-selected when the SelectionUnit is Cell.
Subscribing to the SelectedCellsChanged event
private void SelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
{
}
Private Sub SelectedCellsChanged(sender As Object, e As GridViewSelectedCellsChangedEventArgs)
End Sub
The GridViewSelectedCellsChangedEventArgs class exposes the following specific properties:
- AddedCells—A collection of the cells that have been added to the selection.
- RemovedCells—A collection of the cells that have been removed from the selection.