Share via


ListViewBase.DeselectRange(ItemIndexRange) Method

Definition

Deselects a block of items described by the ItemIndexRange.

void DeselectRange(ItemIndexRange const& itemIndexRange);
public void DeselectRange(ItemIndexRange itemIndexRange);
function deselectRange(itemIndexRange)
Public Sub DeselectRange (itemIndexRange As ItemIndexRange)

Parameters

itemIndexRange
ItemIndexRange

Information about the range of items, including the index of the first and last items in the range, and the number of items.

Examples

Here's how to deselect the first 9 items in a ListView named itemListView.

if (itemListView.SelectionMode == ListViewSelectionMode.Multiple ||
    itemListView.SelectionMode == ListViewSelectionMode.Extended)
{
    itemListView.DeselectRange(new ItemIndexRange(0, 9));
}

Remarks

SelectRange and DeselectRange provide a more efficient way to modify the selection than using the SelectedItems property. When you select items using index ranges, use the SelectedRanges property to get all selected ranges in the list.

When you call DeselectRange, all items in the specified range are deselected, regardless of their original selection state. You can deselect all items in a collection by using an ItemIndexRange with a FirstIndex value of 0 and a Length value equal to the number of items in the collection.

Note

If the ItemsSource implements IItemsRangeInfo, the SelectedItems collection is not updated based on selection in the list. Use the SelectedRanges property instead.

Applies to

See also