BindingList<T> Constructeurs

Définition

Initialise une nouvelle instance de la classe BindingList<T>.

Surcharges

Nom Description
BindingList<T>()

Initialise une nouvelle instance de la classe à l’aide BindingList<T> de valeurs par défaut.

BindingList<T>(IList<T>)

Initialise une nouvelle instance de la BindingList<T> classe avec la liste spécifiée.

BindingList<T>()

Initialise une nouvelle instance de la classe à l’aide BindingList<T> de valeurs par défaut.

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

Exemples

L’exemple de code suivant montre comment construire un nouveau BindingList<T>. Pour obtenir l’exemple complet, consultez la rubrique vue d’ensemble de la 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

Remarques

Le tableau suivant présente les valeurs de propriété initiales d’une instance de BindingList<T> classe.

Propriété Valeur initiale
AllowEdit true
AllowNew true si le type de liste a un constructeur sans paramètre ; sinon, false.
AllowRemove true
RaiseListChangedEvents true

Voir aussi

S’applique à

BindingList<T>(IList<T>)

Initialise une nouvelle instance de la BindingList<T> classe avec la liste spécifiée.

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

Paramètres

list
IList<T>

Éléments IList<T> à contenir dans le BindingList<T>.

Remarques

Utilisez-le BindingList<T> pour créer un BindingList<T> qui est soutenu par list, ce qui garantit que les modifications à list refléter dans le BindingList<T>.

Le tableau suivant présente les valeurs de propriété initiales d’une instance de BindingList<T> classe.

Propriété Valeur initiale
AllowEdit true
AllowNew true si le type de liste a un constructeur sans paramètre ; sinon, false.
AllowRemove true
RaiseListChangedEvents true

Voir aussi

S’applique à