ISelectionItemProvider.RemoveFromSelection Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menghapus elemen saat ini dari kumpulan item terpilih.
public:
void RemoveFromSelection();
public void RemoveFromSelection ();
abstract member RemoveFromSelection : unit -> unit
Public Sub RemoveFromSelection ()
Contoh
Contoh kode berikut menghapus item dari kumpulan item yang dipilih.
/// <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
Keterangan
Kirim yang ElementRemovedFromSelectionEvent sesuai.
Catatan
Aturan ini tidak bergantung pada apakah kontainer mengizinkan satu atau beberapa pilihan, atau pada metode apa yang digunakan untuk mengubah pilihan. Hanya hasilnya yang penting.
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk