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 送信します。

Note

この規則は、コンテナーで 1 つまたは複数の選択を許可するかどうか、または選択を変更するために使用されたメソッドに依存しません。 結果だけが重要です。

適用対象

こちらもご覧ください