BindingList<T> Construtores

Definição

Inicializa uma nova instância da classe BindingList<T>.

Sobrecargas

Nome Description
BindingList<T>()

Inicializa uma nova instância da BindingList<T> classe usando valores padrão.

BindingList<T>(IList<T>)

Inicializa uma nova instância da BindingList<T> classe com a lista especificada.

BindingList<T>()

Inicializa uma nova instância da BindingList<T> classe usando valores padrão.

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

Exemplos

O exemplo de código a seguir demonstra como construir um novo BindingList<T>. Para obter o exemplo completo, consulte o tópico de visão geral da BindingList<T> classe.

// 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

Comentários

A tabela a seguir mostra valores de propriedade iniciais para uma instância da BindingList<T> classe.

Property Valor Inicial
AllowEdit true
AllowNew true se o tipo de lista tiver um construtor sem parâmetros; caso contrário, false.
AllowRemove true
RaiseListChangedEvents true

Confira também

Aplica-se a

BindingList<T>(IList<T>)

Inicializa uma nova instância da BindingList<T> classe com a 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>

Um IList<T> dos itens a serem contidos no BindingList<T>.

Comentários

Use-o BindingList<T>BindingList<T>para criar um BindingList<T> que seja apoiado, listo que garante que as alterações sejam list refletidas no .

A tabela a seguir mostra valores de propriedade iniciais para uma instância da BindingList<T> classe.

Property Valor Inicial
AllowEdit true
AllowNew true se o tipo de lista tiver um construtor sem parâmetros; caso contrário, false.
AllowRemove true
RaiseListChangedEvents true

Confira também

Aplica-se a