다음을 통해 공유


ISelectionItemProvider.RemoveFromSelection 메서드

정의

선택한 항목 컬렉션에서 현재 요소를 제거합니다.

public:
 void RemoveFromSelection();
public void RemoveFromSelection ();
abstract member RemoveFromSelection : unit -> unit
Public Sub RemoveFromSelection ()

예제

다음 예제 코드는 선택한 항목의 컬렉션에서 항목을 제거합니다.

/// <summary>
/// Removes the item from the selection in list boxes that support 
/// multiple selection or no selection at all.
/// </summary>
/// <remarks>
/// selectedItems is the collection of selected ListItems.
/// </remarks>
public void RemoveFromSelection()
{
    // Return if the item is already selected.
    if (((ISelectionItemProvider)this).IsSelected)
        return;
    if (((ISelectionProvider)this).IsSelectionRequired & selectedItems.Count <= 0)
        throw new InvalidOperationException("Operation cannot be performed.");

    selectedItems.Remove(this);
    // TODO: Update UI.
}
''' <summary>
''' Removes the item from the selection in list boxes that support 
''' multiple selection or no selection at all.
''' </summary>
''' <remarks>
''' selectedItems is the collection of selected ListItems.
''' </remarks>
Public Sub RemoveFromSelection() Implements ISelectionItemProvider.RemoveFromSelection
    ' Return if the item is already selected.
    If (CType(Me, ISelectionItemProvider)).IsSelected Then
        Return
    End If
    If (CType(Me, ISelectionProvider)).IsSelectionRequired And selectedItems.Count <= 0 Then
        Throw New InvalidOperationException("Operation cannot be performed.")
    End If

    selectedItems.Remove(Me)
    ' TODO: Update UI.
End Sub
/// <summary>
/// Specifies whether the item is selected.
/// </summary>
/// <remarks>
/// selectedItems is the collection of selected ListItems.
/// </remarks>
public bool IsSelected
{
    get
    {
        return selectedItems.Contains(this);
    }
}
''' <summary>
''' Specifies whether the item is selected.
''' </summary>
''' <remarks>
''' selectedItems is the collection of selected ListItems.
''' </remarks>
Public ReadOnly Property IsSelected() As Boolean Implements ISelectionItemProvider.IsSelected
    Get
        Return selectedItems.Contains(Me)
    End Get
End Property

설명

ElementRemovedFromSelectionEvent 적절하게 보냅니다.

참고

이 규칙은 컨테이너가 단일 또는 여러 선택을 허용하는지 또는 선택 영역을 변경하는 데 사용된 메서드에 따라 달라지지 않습니다. 결과만 중요합니다.

적용 대상

추가 정보