BindingList<T> 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 BindingList<T> 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| BindingList<T>() |
使用默认值初始化类的新实例 BindingList<T> 。 |
| BindingList<T>(IList<T>) |
使用指定的列表初始化类的新实例 BindingList<T> 。 |
BindingList<T>()
- Source:
- BindingList.cs
- Source:
- BindingList.cs
- Source:
- BindingList.cs
- Source:
- BindingList.cs
- Source:
- 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>)
- Source:
- BindingList.cs
- Source:
- BindingList.cs
- Source:
- BindingList.cs
- Source:
- BindingList.cs
- Source:
- 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 |