ListViewBase.DeselectRange(ItemIndexRange) ListViewBase.DeselectRange(ItemIndexRange) ListViewBase.DeselectRange(ItemIndexRange) ListViewBase.DeselectRange(ItemIndexRange) Method

Definition

Deselects a block of items described by the ItemIndexRange.

public : void DeselectRange(ItemIndexRange itemIndexRange)
void DeselectRange(ItemIndexRange itemIndexRange) const;
public void DeselectRange(ItemIndexRange itemIndexRange)
Public Sub DeselectRange(itemIndexRange As ItemIndexRange)

Parameters

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

See also