BindingList<T> Конструкторы

Определение

Инициализирует новый экземпляр класса BindingList<T>.

Перегрузки

Имя Описание
BindingList<T>()

Инициализирует новый экземпляр класса с помощью значений BindingList<T> по умолчанию.

BindingList<T>(IList<T>)

Инициализирует новый экземпляр BindingList<T> класса с указанным списком.

BindingList<T>()

Исходный код:
BindingList.cs
Исходный код:
BindingList.cs
Исходный код:
BindingList.cs
Исходный код:
BindingList.cs
Исходный код:
BindingList.cs

Инициализирует новый экземпляр класса с помощью значений BindingList<T> по умолчанию.

public:
 BindingList();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
public BindingList();
public BindingList();
Public Sub New ()
Атрибуты

Примеры

В следующем примере кода показано, как создать новый BindingList<T>код. Полный пример см. в BindingList<T> разделе обзора класса.

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

Комментарии

В следующей таблице показаны начальные значения свойств для экземпляра BindingList<T> класса.

Недвижимость Начальное значение
AllowEdit true
AllowNew true Значение , если тип списка имеет конструктор без параметров; falseв противном случае .
AllowRemove true
RaiseListChangedEvents true

См. также раздел

Применяется к

BindingList<T>(IList<T>)

Исходный код:
BindingList.cs
Исходный код:
BindingList.cs
Исходный код:
BindingList.cs
Исходный код:
BindingList.cs
Исходный код:
BindingList.cs

Инициализирует новый экземпляр BindingList<T> класса с указанным списком.

public:
 BindingList(System::Collections::Generic::IList<T> ^ list);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
public BindingList(System.Collections.Generic.IList<T> list);
public BindingList(System.Collections.Generic.IList<T> list);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")>]
new System.ComponentModel.BindingList<'T> : System.Collections.Generic.IList<'T> -> System.ComponentModel.BindingList<'T>
new System.ComponentModel.BindingList<'T> : System.Collections.Generic.IList<'T> -> System.ComponentModel.BindingList<'T>
Public Sub New (list As IList(Of T))

Параметры

list
IList<T>

Элемент IList<T> , содержащийся в элементе BindingList<T>.

Атрибуты

Комментарии

Используйте это BindingList<T> для создания поддерживаемой BindingList<T>listплатформой, которая гарантирует, что измененияlist, которые будут отражены в .BindingList<T>

В следующей таблице показаны начальные значения свойств для экземпляра BindingList<T> класса.

Недвижимость Начальное значение
AllowEdit true
AllowNew true Значение , если тип списка имеет конструктор без параметров; falseв противном случае .
AllowRemove true
RaiseListChangedEvents true

См. также раздел

Применяется к