BindingList<T> Construtores

Definição

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

Sobrecargas

Name Description
BindingList<T>()

Inicializa uma nova instância da BindingList<T> classe usando valores por defeito.

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 por defeito.

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

Exemplos

O exemplo de código seguinte demonstra como construir um novo BindingList<T>. Para o exemplo completo, veja o tópico de resumo BindingList<T> da aula.

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

Observações

A tabela seguinte mostra os valores iniciais das propriedades para uma instância de 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

Ver 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> de itens a ser contido no BindingList<T>.

Observações

Use isto BindingList<T> para criar um BindingList<T> que é suportado por list, o que garante que as alterações a list são refletidas no BindingList<T>.

A tabela seguinte mostra os valores iniciais das propriedades para uma instância de 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

Ver também

Aplica-se a