New to Telerik UI for WPF? Download free 30-day trial

Selection

This article will go through the selection mechanisms provided by RadVirtualGrid.

The ability the user to be able to select rows or cells can be controlled through the CanUserSelect boolean property.

Selection Modes

RadVirtualGrid provides three selection modes. The needed one can be applied through the SelectionMode property, which is an enumeration that has the following values.

  • Single - only one item can be selected at a time. (default value)

  • Multiple - items are added to the selection when they get clicked and get removed when they get clicked again.

  • Extended - items are added to the selection only by combining the mouse clicks with the Ctrl or Shift key.

More information regarding the Multiple and Extended selection can be found in the Multiple Selection topic.

Selection Units

The selection functionality of the control exposes three selection units. Manipulating it can be done through the SelectionUnit enumeration.

  • Cell - the clicked cell is selected only. Depending on the value of the SelectionModes property you can have more than one selected cell.

  • Row - this is the default value. Clicking within the cells will select the row.

  • Column - clicking within the cells of a given column selects the whole column.

Column Selection

When the SelectionUnit of RadVirtualGrid is set to Column, all cells within the selected column will be added to the SelectedCells collection irrelevant to whether the SelectionMode is set or not.

Figure 2: RadVirtualGrid with SelectionUnit set to Column

RadVirtualGrid with SelectionUnit set to Column

Events

The AddedItems and RemovedItems properties can be utilized only when the SelectionInit of RadVirtualGrid is set to Row or Column.

  • SelectedCellsChanging - raised when the SelectedCells collection is about to change. The event arguments expose 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.

Example 1: Subscribing to the SelectionCellsChanging event

private void VirtualGrid_SelectedCellsChanging(object sender, VirtualGridSelectedCellsChangingEventArgs e) 
    { 
 
    } 
  • SelectedCellsChanged - raised when the SelectedCells collection has changed. The event arguments expose the following specific properties: AddedItems and RemovedItems.

Example 2: Subscribing to the SelectionCellsChanged event

private void VirtualGrid_SelectedCellsChanged(object sender, VirtualGridSelectedCellsChangedEventArgs e) 
    { 
 
    } 
  • SelectionChanged - raised when the selection of the control has changed. It is triggered only when the SelectionUnit is different from Cell. The event arguments expose the following specific properties: AddedItems and RemovedItems.

Example 3: Subscribing to the SelectionChanged event

  private void VirtualGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) 
    { 
 
    } 

See Also

In this article