Edit this page

Selection

There are a couple of events relevant to the selection in RadGridView: SelectionChanging, SelectionChanged, CurrentCellChanged, SelectedCellsChanging and SelectedCellsChanged. The sequence of the events depends on the SelectionUnit property:

  • FullRow - the SelectionChanged is fired first and after that the CurrentCellChanged event fires

  • Cell - the SelectedCellsChanged is fired first and after that the CurrentCellChanged event fires

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 event

It is fired once a selection is about to be performed and a change in the SelectedItems collection is to be executed (a row is to be selected or un-selected and SelectionUnit="FullRow").

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 enables canceling the selection.

SelectionChanged event

Fires each time there is a change in the SelectedItems collection (a row has been selected or un-selected and SelectionUnit="FullRow").

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 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

CurrentCellChanged event

This event is raised when a cell is selected. It fires before the SelectionChanged (when SelectionUnit="FullRow") or before the SelectedCellsChanged (when SelectionUnit="Cell").

private void CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e)
{
}
Private Sub CurrentCellChanged(ByVal sender As Object, ByVal e As GridViewCurrentCellChangedEventArgs)
End Sub

The GridViewCurrentCellChangedEventArgs class exposes the following specific properties:

  • NewCell - an instance of the newly selected cell

  • OldCell - an instance of the previously selected cell

SelectedCellsChanging event

This event is fired on the time a change in the SelectedCells collection is about to be performed (a cell is to be selected or un-selected when the SelectionUnit="Cell").

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 cell(s) that has/have been added to the selection

  • RemovedCells - a collection of the cell(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 enables canceling the cell selection

SelectedCellsChanged event

Fires each time there is change in the SelectedCells collection (a cell has been selected or un-selected when the SelectionUnit="Cell").

private void gridView_SelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
{
}
Private Sub gridView_SelectedCellsChanged(sender As Object, e As GridViewSelectedCellsChangedEventArgs)
End Sub

The GridViewSelectedCellsChangedEventArgs class exposes the following specific properties:

  • AddedCells - a collection of the cell(s) that has/have been added to the selection

  • RemovedCells - a collection of the cell(s) that has/have been removed from the selection

See Also