IEditableCollectionView.Remove(Object) 메서드

정의

컬렉션에서 지정된 항목을 제거합니다.

public:
 void Remove(System::Object ^ item);
public void Remove(object item);
abstract member Remove : obj -> unit
Public Sub Remove (item As Object)

매개 변수

item
Object

제거할 항목입니다.

예제

다음 예제에서는 컬렉션에서 항목을 제거할 수 있는지 여부를 확인 하기 위해 호출 CanRemove 합니다. 항목을 제거할 수 있는 경우 예제에서는 사용자에게 작업을 확인하라는 메시지를 표시하고 사용자가 예를 클릭하면 호출 Remove 합니다. 전체 샘플은 IEditableCollectionView 샘플을 사용하여 컬렉션 변경을 참조하세요.

IEditableCollectionView editableCollectionView =
        itemsControl.Items;

if (!editableCollectionView.CanRemove)
{
    _ = MessageBox.Show("You cannot remove items from the list.");
    return;
}

if (MessageBox.Show("Are you sure you want to remove " + item.Description,
                    "Remove Item", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
    editableCollectionView.Remove(itemsControl.SelectedItem);
}
Dim editableCollectionView As IEditableCollectionView = TryCast(itemsControl.Items, IEditableCollectionView)

If Not editableCollectionView.CanRemove Then
    MessageBox.Show("You cannot remove items from the list.")
    Return
End If

If MessageBox.Show("Are you sure you want to remove " & item.Description, "Remove Item", MessageBoxButton.YesNo) = MessageBoxResult.Yes Then
    editableCollectionView.Remove(itemsControl.SelectedItem)
End If

설명

컬렉션 Remove 에 없는 경우 item 아무 작업도 수행하지 않습니다.

적용 대상