BindingList<T> Construtores

Definição

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

Sobrecargas

BindingList<T>()

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

BindingList<T>(IList<T>)

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

BindingList<T>()

Origem:
BindingList.cs
Origem:
BindingList.cs
Origem:
BindingList.cs

Inicializa uma nova instância da classe BindingList<T> 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 visão geral da BindingList<T> classe.

    // Declare a new BindingListOfT with the Part business object.
    BindingList<Part> listOfParts; 
    private void InitializeListOfParts()
    {
        // Create the new BindingList of Part type.
        listOfParts = new BindingList<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));
    }
' 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 .

Propriedade 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>)

Origem:
BindingList.cs
Origem:
BindingList.cs
Origem:
BindingList.cs

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

Comentários

Use isso BindingList<T> para criar um BindingList<T> que é apoiado por list, que garante que as alterações em list sejam refletidas no BindingList<T>.

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

Propriedade 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