ListBox.SelectedItems Property

Definition

Obtiene los elementos actualmente seleccionados.Gets the currently selected items.

public:
 property System::Collections::IList ^ SelectedItems { System::Collections::IList ^ get(); };
[System.ComponentModel.Bindable(true)]
public System.Collections.IList SelectedItems { get; }
member this.SelectedItems : System.Collections.IList
Public ReadOnly Property SelectedItems As IList

Property Value

IList

Devuelve una colección de los elementos actualmente seleccionados.Returns a collection of the currently selected items.

Attributes

Exceptions

La propiedad SelectionMode se establece en Single.The SelectionMode property is set to Single.

Examples

En el ejemplo siguiente se muestra cómo usar la propiedad SelectedItems para determinar si un cuadro de lista tiene elementos seleccionados.The following example shows how to use the SelectedItems property to determine whether a list box has any selected items.

private void SelectedItems(object sender, RoutedEventArgs e)
{
    if (lb.SelectedItem != null)
    {
        label1.Content = "Has " + (lb.SelectedItems.Count.ToString()) + " item(s) selected.";
    }
}
Private Sub SelectedItems(ByVal sender As Object, ByVal e As RoutedEventArgs)
    If lb.SelectedItem IsNot Nothing Then
        label1.Content = "Has " & (lb.SelectedItems.Count.ToString()) & " item(s) selected."
    End If
End Sub

Remarks

Esta propiedad está pensada para usarse cuando SelectionMode no es igual a Single.This property is meant to be used when SelectionMode does not equal Single. Si el modo de selección es Single se SelectedItemla propiedad correcta.If the selection mode is Single the correct property to use is SelectedItem.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field SelectedItemsProperty
Propiedades de metadatos establecidas en trueMetadata properties set to true NoneNone

Applies to