IEditableCollectionView.Remove(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Removes the specified item from the collection.
public:
void Remove(System::Object ^ item);
public void Remove(object item);
abstract member Remove : obj -> unit
Public Sub Remove (item As Object)
Parameters
- item
- Object
The item to remove.
Examples
The following example calls CanRemove to check whether an item can be removed from the collection. If an item can be removed, the example prompts the user to confirm the action and calls Remove if the user clicks Yes. For the entire sample, see Changing a Collection by Using IEditableCollectionView Sample.
IEditableCollectionView editableCollectionView =
itemsControl.Items as IEditableCollectionView;
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
Remarks
If item
is not in the collection, Remove does nothing.
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET