BindingList<T> Constructores

Definición

Inicializa una nueva instancia de la clase BindingList<T>.

Sobrecargas

Nombre Description
BindingList<T>()

Inicializa una nueva instancia de la BindingList<T> clase con valores predeterminados.

BindingList<T>(IList<T>)

Inicializa una nueva instancia de la BindingList<T> clase con la lista especificada.

BindingList<T>()

Inicializa una nueva instancia de la BindingList<T> clase con valores predeterminados.

public:
 BindingList();
public BindingList();
Public Sub New ()

Ejemplos

En el ejemplo de código siguiente se muestra cómo construir un nuevo BindingList<T>. Para obtener el ejemplo completo, consulte el tema de información general de la BindingList<T> clase.

// Declare a new BindingListOfT with the Part business object.
BindingList<Part> listOfParts;
void InitializeListOfParts()
{
    // Create the new BindingList of Part type.
    listOfParts = new BindingList<Part>
    {
        // Allow new parts to be added, but not removed once committed.        
        AllowNew = true,
        AllowRemove = false,

        // Raise ListChanged events when new parts are added.
        RaiseListChangedEvents = true,

        // Do not allow parts to be edited.
        AllowEdit = false
    };

    // Add a couple of parts to the list.
    listOfParts.Add(new Part("Widget", 1234));
    listOfParts.Add(new Part("Gadget", 5647));
}
' Declare a new BindingListOfT with the Part business object.
Private WithEvents listOfParts As BindingList(Of Part)

Private Sub InitializeListOfParts()

    ' Create the new BindingList of Part type.
    listOfParts = New BindingList(Of Part)

    ' Allow new parts to be added, but not removed once committed.        
    listOfParts.AllowNew = True
    listOfParts.AllowRemove = False

    ' Raise ListChanged events when new parts are added.
    listOfParts.RaiseListChangedEvents = True

    ' Do not allow parts to be edited.
    listOfParts.AllowEdit = False

    ' Add a couple of parts to the list.
    listOfParts.Add(New Part("Widget", 1234))
    listOfParts.Add(New Part("Gadget", 5647))

End Sub

Comentarios

En la tabla siguiente se muestran los valores de propiedad iniciales de una instancia de BindingList<T> clase.

Propiedad Valor inicial
AllowEdit true
AllowNew true si el tipo de lista tiene un constructor sin parámetros; de lo contrario, false.
AllowRemove true
RaiseListChangedEvents true

Consulte también

Se aplica a

BindingList<T>(IList<T>)

Inicializa una nueva instancia de la BindingList<T> clase con la lista especificada.

public:
 BindingList(System::Collections::Generic::IList<T> ^ list);
public BindingList(System.Collections.Generic.IList<T> list);
new System.ComponentModel.BindingList<'T> : System.Collections.Generic.IList<'T> -> System.ComponentModel.BindingList<'T>
Public Sub New (list As IList(Of T))

Parámetros

list
IList<T>

de IList<T> elementos que se van a contener en .BindingList<T>

Comentarios

Úselo BindingList<T> para crear un BindingList<T> objeto respaldado por list, que garantiza que los cambios list en se reflejen en .BindingList<T>

En la tabla siguiente se muestran los valores de propiedad iniciales de una instancia de BindingList<T> clase.

Propiedad Valor inicial
AllowEdit true
AllowNew true si el tipo de lista tiene un constructor sin parámetros; de lo contrario, false.
AllowRemove true
RaiseListChangedEvents true

Consulte también

Se aplica a