ControlBindingsCollection Klasa

Definicja

Reprezentuje zbieranie powiązań danych dla kontrolki.

public ref class ControlBindingsCollection : System::Windows::Forms::BindingsCollection
[System.ComponentModel.TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class ControlBindingsCollection : System.Windows.Forms.BindingsCollection
[System.ComponentModel.TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class ControlBindingsCollection : System.Windows.Forms.BindingsCollection
[System.ComponentModel.TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public class ControlBindingsCollection : System.Windows.Forms.BindingsCollection
[<System.ComponentModel.TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type ControlBindingsCollection = class
    inherit BindingsCollection
[<System.ComponentModel.TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type ControlBindingsCollection = class
    inherit BindingsCollection
[<System.ComponentModel.TypeConverter("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
type ControlBindingsCollection = class
    inherit BindingsCollection
Public Class ControlBindingsCollection
Inherits BindingsCollection
Dziedziczenie
Atrybuty

Przykłady

Poniższy przykład kodu dodaje Binding obiekty do ControlBindingsCollection pięciu kontrolek: cztery TextBox kontrolki i kontrolkę DateTimePicker . Dostęp ControlBindingsCollection do obiektu Control jest uzyskiwany za pośrednictwem DataBindings właściwości klasy .

protected:
   void BindControls()
   {
      /* Create two Binding objects for the first two TextBox 
         controls. The data-bound property for both controls 
         is the Text property. The data source is a DataSet 
         (ds). The data member is the navigation path: 
         TableName.ColumnName. */
      textBox1->DataBindings->Add( gcnew Binding(
         "Text",ds,"customers.custName" ) );
      textBox2->DataBindings->Add( gcnew Binding(
         "Text",ds,"customers.custID" ) );
      
      /* Bind the DateTimePicker control by adding a new Binding. 
         The data member of the DateTimePicker is a navigation path:
         TableName.RelationName.ColumnName. */
      DateTimePicker1->DataBindings->Add( gcnew Binding(
         "Value",ds,"customers.CustToOrders.OrderDate" ) );
      
      /* Create a new Binding using the DataSet and a 
         navigation path(TableName.RelationName.ColumnName).
         Add event delegates for the Parse and Format events to 
         the Binding object, and add the object to the third 
         TextBox control's BindingsCollection. The delegates 
         must be added before adding the Binding to the 
         collection; otherwise, no formatting occurs until 
         the Current object of the BindingManagerBase for 
         the data source changes. */
      Binding^ b = gcnew Binding(
         "Text",ds,"customers.custToOrders.OrderAmount" );
      b->Parse += gcnew ConvertEventHandler(
         this, &Form1::CurrencyStringToDecimal );
      b->Format += gcnew ConvertEventHandler(
         this, &Form1::DecimalToCurrencyString );
      textBox3->DataBindings->Add( b );
      
      /*Bind the fourth TextBox to the Value of the 
         DateTimePicker control. This demonstates how one control
         can be data-bound to another.*/
      textBox4->DataBindings->Add( "Text", DateTimePicker1, "Value" );
      
      // Get the BindingManagerBase for the textBox4 Binding.
      BindingManagerBase^ bmText = this->BindingContext[
         DateTimePicker1 ];
      
      /* Print the Type of the BindingManagerBase, which is 
         a PropertyManager because the data source
         returns only a single property value. */
      Console::WriteLine( bmText->GetType() );
      
      // Print the count of managed objects, which is one.
      Console::WriteLine( bmText->Count );
      
      // Get the BindingManagerBase for the Customers table. 
      bmCustomers = this->BindingContext[ds, "Customers"];
      
      /* Print the Type and count of the BindingManagerBase.
         Because the data source inherits from IBindingList,
         it is a RelatedCurrencyManager (a derived class of
         CurrencyManager). */
      Console::WriteLine( bmCustomers->GetType() );
      Console::WriteLine( bmCustomers->Count );
      
      /* Get the BindingManagerBase for the Orders of the current
         customer using a navigation path: TableName.RelationName. */
      bmOrders = this->BindingContext[ds, "customers.CustToOrders"];
   }
protected void BindControls()
{
   /* Create two Binding objects for the first two TextBox 
   controls. The data-bound property for both controls 
   is the Text property. The data source is a DataSet 
   (ds). The data member is the navigation path: 
   TableName.ColumnName. */
   textBox1.DataBindings.Add(new Binding
   ("Text", ds, "customers.custName"));
   textBox2.DataBindings.Add(new Binding
   ("Text", ds, "customers.custID"));
      
   /* Bind the DateTimePicker control by adding a new Binding. 
   The data member of the DateTimePicker is a navigation path:
   TableName.RelationName.ColumnName. */
   DateTimePicker1.DataBindings.Add(new 
   Binding("Value", ds, "customers.CustToOrders.OrderDate"));

   /* Create a new Binding using the DataSet and a 
   navigation path(TableName.RelationName.ColumnName).
   Add event delegates for the Parse and Format events to 
   the Binding object, and add the object to the third 
   TextBox control's BindingsCollection. The delegates 
   must be added before adding the Binding to the 
   collection; otherwise, no formatting occurs until 
   the Current object of the BindingManagerBase for 
   the data source changes. */
   Binding b = new Binding
   ("Text", ds, "customers.custToOrders.OrderAmount");
   b.Parse+=new ConvertEventHandler(CurrencyStringToDecimal);
   b.Format+=new ConvertEventHandler(DecimalToCurrencyString);
   textBox3.DataBindings.Add(b);

   /*Bind the fourth TextBox to the Value of the 
   DateTimePicker control. This demonstates how one control
   can be data-bound to another.*/
   textBox4.DataBindings.Add("Text", DateTimePicker1,"Value");

   // Get the BindingManagerBase for the textBox4 Binding.
   BindingManagerBase bmText = this.BindingContext
   [DateTimePicker1];

   /* Print the Type of the BindingManagerBase, which is 
   a PropertyManager because the data source
   returns only a single property value. */
   Console.WriteLine(bmText.GetType().ToString());

   // Print the count of managed objects, which is one.
   Console.WriteLine(bmText.Count);

   // Get the BindingManagerBase for the Customers table. 
   bmCustomers = this.BindingContext [ds, "Customers"];

   /* Print the Type and count of the BindingManagerBase.
   Because the data source inherits from IBindingList,
   it is a RelatedCurrencyManager (a derived class of
   CurrencyManager). */
   Console.WriteLine(bmCustomers.GetType().ToString());
   Console.WriteLine(bmCustomers.Count);
   
   /* Get the BindingManagerBase for the Orders of the current
   customer using a navigation path: TableName.RelationName. */ 
   bmOrders = this.BindingContext[ds, "customers.CustToOrders"];
}
Protected Sub BindControls()
    ' Create two Binding objects for the first two TextBox 
    ' controls. The data-bound property for both controls 
    ' is the Text property. The data source is a DataSet 
    ' (ds). The data member is the navigation path: 
    ' TableName.ColumnName. 
    textBox1.DataBindings.Add _
       (New Binding("Text", ds, "customers.custName"))
    textBox2.DataBindings.Add _
       (New Binding("Text", ds, "customers.custID"))
    
    ' Bind the DateTimePicker control by adding a new Binding. 
    ' The data member of the DateTimePicker is a navigation path:
    ' TableName.RelationName.ColumnName. 
    DateTimePicker1.DataBindings.Add _
       (New Binding("Value", ds, "customers.CustToOrders.OrderDate"))
    
    ' Create a new Binding using the DataSet and a 
    ' navigation path(TableName.RelationName.ColumnName).
    ' Add event delegates for the Parse and Format events to 
    ' the Binding object, and add the object to the third 
    ' TextBox control's BindingsCollection. The delegates 
    ' must be added before adding the Binding to the 
    ' collection; otherwise, no formatting occurs until 
    ' the Current object of the BindingManagerBase for 
    ' the data source changes. 
    Dim b As New Binding("Text", ds, "customers.custToOrders.OrderAmount")
    AddHandler b.Parse, AddressOf CurrencyStringToDecimal
    AddHandler b.Format, AddressOf DecimalToCurrencyString
    textBox3.DataBindings.Add(b)
    
    ' Bind the fourth TextBox to the Value of the 
    ' DateTimePicker control. This demonstates how one control
    ' can be data-bound to another.
    textBox4.DataBindings.Add("Text", DateTimePicker1, "Value")
    
    ' Get the BindingManagerBase for the textBox4 Binding.
    Dim bmText As BindingManagerBase = Me.BindingContext(DateTimePicker1)
    
    ' Print the Type of the BindingManagerBase, which is 
    ' a PropertyManager because the data source
    ' returns only a single property value. 
    Console.WriteLine(bmText.GetType().ToString())
    
    ' Print the count of managed objects, which is one.
    Console.WriteLine(bmText.Count)
    
    ' Get the BindingManagerBase for the Customers table. 
    bmCustomers = Me.BindingContext(ds, "Customers")
    
    ' Print the Type and count of the BindingManagerBase.
    ' Because the data source inherits from IBindingList,
    ' it is a RelatedCurrencyManager (a derived class of
    ' CurrencyManager). 
    Console.WriteLine(bmCustomers.GetType().ToString())
    Console.WriteLine(bmCustomers.Count)
    
    ' Get the BindingManagerBase for the Orders of the current
    ' customer using a navigation path: TableName.RelationName. 
    bmOrders = Me.BindingContext(ds, "customers.CustToOrders")
End Sub

Uwagi

Proste powiązanie danych jest realizowane przez dodanie Binding obiektów do obiektu ControlBindingsCollection. Każdy obiekt dziedziczony z Control klasy może uzyskać dostęp do ControlBindingsCollection obiektu za pośrednictwem DataBindings właściwości . Aby uzyskać listę kontrolek systemu Windows obsługujących powiązanie danych, zobacz klasę Binding .

Zawiera ControlBindingsCollection standardowe metody kolekcji, takie jak Add, Cleari Remove.

Aby uzyskać formant, do którego ControlBindingsCollection należy, użyj Control właściwości .

Konstruktory

ControlBindingsCollection(IBindableComponent)

Inicjuje ControlBindingsCollection nowe wystąpienie klasy za pomocą określonej kontrolki możliwej do powiązania.

Właściwości

BindableComponent

IBindableComponent Pobiera kolekcję powiązań, do których należy.

Control

Pobiera kontrolkę, do którego należy kolekcja.

Count

Pobiera całkowitą liczbę powiązań w kolekcji.

(Odziedziczone po BindingsCollection)
DefaultDataSourceUpdateMode

Pobiera lub ustawia wartość domyślną DataSourceUpdateModeBinding elementu w kolekcji.

IsReadOnly

Pobiera wartość wskazującą, czy kolekcja jest przeznaczona tylko do odczytu.

(Odziedziczone po BaseCollection)
IsSynchronized

Pobiera wartość wskazującą, czy dostęp do pliku ICollection jest synchronizowany.

(Odziedziczone po BaseCollection)
Item[Int32]

Pobiera obiekt Binding w określonym indeksie.

(Odziedziczone po BindingsCollection)
Item[String]

Pobiera element Binding określony przez nazwę właściwości kontrolki.

List

Pobiera powiązania w kolekcji jako obiekt.

(Odziedziczone po BindingsCollection)
SyncRoot

Pobiera obiekt, który może służyć do synchronizowania dostępu do obiektu BaseCollection.

(Odziedziczone po BaseCollection)

Metody

Add(Binding)

Dodaje określony Binding element do kolekcji.

Add(String, Object, String)

Binding Tworzy obiekt przy użyciu określonej nazwy właściwości kontrolki, źródła danych i elementu członkowskiego danych oraz dodaje go do kolekcji.

Add(String, Object, String, Boolean)

Tworzy powiązanie z określoną nazwą właściwości kontrolki, źródłem danych, elementem członkowskim danych i informacjami o tym, czy formatowanie jest włączone, i dodaje powiązanie do kolekcji.

Add(String, Object, String, Boolean, DataSourceUpdateMode)

Tworzy powiązanie, które wiąże określoną właściwość kontrolki z określonym elementem członkowskim danych określonego źródła danych, opcjonalnie włączając formatowanie, propagując wartości do źródła danych na podstawie określonego ustawienia aktualizacji i dodając powiązanie do kolekcji.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object)

Tworzy powiązanie, które wiąże określoną właściwość kontrolki z określonym elementem członkowskim danych określonego źródła danych, opcjonalnie włączając formatowanie, propagując wartości do źródła danych na podstawie określonego ustawienia aktualizacji, ustawiając właściwość na określoną wartość po DBNull powrocie ze źródła danych i dodając powiązanie do kolekcji.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String)

Tworzy powiązanie, które wiąże określoną właściwość kontrolki z określonym elementem członkowskim danych określonego źródła danych, opcjonalnie włączając formatowanie przy użyciu określonego ciągu formatu, propagując wartości do źródła danych na podstawie określonego ustawienia aktualizacji, ustawiając właściwość na określoną wartość DBNull po powrocie ze źródła danych i dodając powiązanie do kolekcji.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider)

Tworzy powiązanie, które wiąże określoną właściwość kontrolki z określonym elementem członkowskim danych określonego źródła danych, opcjonalnie włączając formatowanie przy użyciu określonego ciągu formatu, propagując wartości do źródła danych na podstawie określonego ustawienia aktualizacji, ustawiając właściwość na określoną wartość po DBNull powrocie ze źródła danych, ustawiając określonego dostawcę formatu, i dodanie powiązania do kolekcji.

AddCore(Binding)

Dodaje powiązanie do kolekcji.

Clear()

Czyści kolekcję wszelkich powiązań.

ClearCore()

Czyści powiązania w kolekcji.

CopyTo(Array, Int32)

Kopiuje wszystkie elementy bieżącego jednowymiarowego do określonego jednowymiarowego ArrayArray indeksu rozpoczynającego się od określonego indeksu docelowego Array .

(Odziedziczone po BaseCollection)
CreateObjRef(Type)

Tworzy obiekt zawierający wszystkie istotne informacje wymagane do wygenerowania serwera proxy używanego do komunikowania się z obiektem zdalnym.

(Odziedziczone po MarshalByRefObject)
Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetEnumerator()

Pobiera obiekt, który umożliwia iterowanie za pośrednictwem elementów członkowskich kolekcji.

(Odziedziczone po BaseCollection)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetLifetimeService()
Przestarzałe.

Pobiera bieżący obiekt usługi okresu istnienia, który kontroluje zasady okresu istnienia dla tego wystąpienia.

(Odziedziczone po MarshalByRefObject)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
InitializeLifetimeService()
Przestarzałe.

Uzyskuje obiekt usługi okresu istnienia w celu kontrolowania zasad okresu istnienia dla tego wystąpienia.

(Odziedziczone po MarshalByRefObject)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
MemberwiseClone(Boolean)

Tworzy płytkią kopię bieżącego MarshalByRefObject obiektu.

(Odziedziczone po MarshalByRefObject)
OnCollectionChanged(CollectionChangeEventArgs)

CollectionChanged Zgłasza zdarzenie.

(Odziedziczone po BindingsCollection)
OnCollectionChanging(CollectionChangeEventArgs)

CollectionChanging Zgłasza zdarzenie.

(Odziedziczone po BindingsCollection)
Remove(Binding)

Usuwa określony Binding element z kolekcji.

RemoveAt(Int32)

Usuwa element Binding w określonym indeksie.

RemoveCore(Binding)

Usuwa określone powiązanie z kolekcji.

ShouldSerializeMyAll()

Pobiera wartość wskazującą, czy kolekcja powinna być serializowana.

(Odziedziczone po BindingsCollection)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Zdarzenia

CollectionChanged

Występuje, gdy kolekcja uległa zmianie.

(Odziedziczone po BindingsCollection)
CollectionChanging

Występuje, gdy kolekcja ma ulec zmianie.

(Odziedziczone po BindingsCollection)

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy obiektu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy IEnumerable elementu na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy