BindingList<T> Konstruktory
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Inicializuje novou instanci BindingList<T> třídy.
Přetížení
| Name | Description |
|---|---|
| BindingList<T>() |
Inicializuje novou instanci BindingList<T> třídy pomocí výchozích hodnot. |
| BindingList<T>(IList<T>) |
Inicializuje novou instanci BindingList<T> třídy se zadaným seznamem. |
BindingList<T>()
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
Inicializuje novou instanci BindingList<T> třídy pomocí výchozích hodnot.
public:
BindingList();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors. PropertyDescriptors require unreferenced code.")]
public BindingList();
public BindingList();
Public Sub New ()
- Atributy
Příklady
Následující příklad kódu ukazuje, jak vytvořit nový BindingList<T>. Úplný příklad najdete v tématu přehledu BindingList<T> třídy.
// 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
Poznámky
Následující tabulka zobrazuje počáteční hodnoty vlastností pro instanci BindingList<T> třídy.
| Vlastnictví | Počáteční hodnota |
|---|---|
| AllowEdit | true |
| AllowNew |
truepokud typ seznamu má konstruktor bez parametrů; v opačném případě . false |
| AllowRemove | true |
| RaiseListChangedEvents | true |
Viz také
Platí pro
BindingList<T>(IList<T>)
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
- Zdroj:
- BindingList.cs
Inicializuje novou instanci BindingList<T> třídy se zadaným seznamem.
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))
Parametry
- list
- IList<T>
Položky IList<T> , které mají být obsaženy v sadě BindingList<T>.
- Atributy
Poznámky
Použijte to BindingList<T> k vytvoření BindingList<T> , které je podporováno list, což zajišťuje, že se změny, které se list projeví v souboru BindingList<T>.
Následující tabulka zobrazuje počáteční hodnoty vlastností pro instanci BindingList<T> třídy.
| Vlastnictví | Počáteční hodnota |
|---|---|
| AllowEdit | true |
| AllowNew |
truepokud typ seznamu má konstruktor bez parametrů; v opačném případě . false |
| AllowRemove | true |
| RaiseListChangedEvents | true |