Share via


ControlBindingsCollection Kelas

Definisi

Mewakili pengumpulan pengikatan data untuk kontrol.

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
Warisan
Atribut

Contoh

Contoh kode berikut menambahkan Binding objek ke ControlBindingsCollection dari lima kontrol: empat TextBox kontrol dan DateTimePicker kontrol. ControlBindingsCollection diakses melalui DataBindings properti Control kelas .

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

Keterangan

Pengikatan data sederhana dilakukan dengan menambahkan Binding objek ke ControlBindingsCollection. Objek apa pun yang mewarisi dari Control kelas dapat mengakses ControlBindingsCollection melalui DataBindings properti . Untuk daftar kontrol Windows yang mendukung pengikatan data, lihat Binding kelas .

ControlBindingsCollection berisi metode pengumpulan standar seperti Add, , Cleardan Remove.

Untuk mendapatkan kontrol miliknya ControlBindingsCollection , gunakan Control properti .

Konstruktor

ControlBindingsCollection(IBindableComponent)

Menginisialisasi instans ControlBindingsCollection baru kelas dengan kontrol yang dapat diikat yang ditentukan.

Properti

BindableComponent

IBindableComponent Mendapatkan koleksi pengikatan milik.

Control

Mendapatkan kontrol tempat koleksi berada.

Count

Mendapatkan jumlah total pengikatan dalam koleksi.

(Diperoleh dari BindingsCollection)
DefaultDataSourceUpdateMode

Mendapatkan atau mengatur default DataSourceUpdateMode untuk Binding dalam koleksi.

IsReadOnly

Mendapatkan nilai yang menunjukkan apakah koleksi bersifat baca-saja.

(Diperoleh dari BaseCollection)
IsSynchronized

Mendapatkan nilai yang menunjukkan apakah akses ke disinkronkan ICollection .

(Diperoleh dari BaseCollection)
Item[Int32]

Mendapatkan pada Binding indeks yang ditentukan.

(Diperoleh dari BindingsCollection)
Item[String]

Mendapatkan yang Binding ditentukan oleh nama properti kontrol.

List

Mendapatkan pengikatan dalam koleksi sebagai objek.

(Diperoleh dari BindingsCollection)
SyncRoot

Mendapatkan objek yang dapat digunakan untuk menyinkronkan akses ke BaseCollection.

(Diperoleh dari BaseCollection)

Metode

Add(Binding)

Menambahkan yang ditentukan Binding ke koleksi.

Add(String, Object, String)

Binding Membuat menggunakan nama properti kontrol, sumber data, dan anggota data yang ditentukan, dan menambahkannya ke koleksi.

Add(String, Object, String, Boolean)

Membuat pengikatan dengan nama properti kontrol, sumber data, anggota data, dan informasi yang ditentukan tentang apakah pemformatan diaktifkan, dan menambahkan pengikatan ke koleksi.

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

Membuat pengikatan yang mengikat properti kontrol yang ditentukan ke anggota data tertentu dari sumber data yang ditentukan, secara opsional mengaktifkan pemformatan, menyebarkan nilai ke sumber data berdasarkan pengaturan pembaruan yang ditentukan, dan menambahkan pengikatan ke koleksi.

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

Membuat pengikatan yang mengikat properti kontrol yang ditentukan ke anggota data tertentu dari sumber data yang ditentukan, secara opsional mengaktifkan pemformatan, menyebarkan nilai ke sumber data berdasarkan pengaturan pembaruan yang ditentukan, mengatur properti ke nilai yang ditentukan saat DBNull dikembalikan dari sumber data, dan menambahkan pengikatan ke koleksi.

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

Membuat pengikatan yang mengikat properti kontrol yang ditentukan ke anggota data yang ditentukan dari sumber data yang ditentukan, secara opsional mengaktifkan pemformatan dengan string format yang ditentukan, menyebarkan nilai ke sumber data berdasarkan pengaturan pembaruan yang ditentukan, mengatur properti ke nilai yang ditentukan saat DBNull dikembalikan dari sumber data, dan menambahkan pengikatan ke koleksi.

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

Membuat pengikatan yang mengikat properti kontrol yang ditentukan ke anggota data tertentu dari sumber data yang ditentukan, secara opsional mengaktifkan pemformatan dengan string format yang ditentukan, menyebarkan nilai ke sumber data berdasarkan pengaturan pembaruan yang ditentukan, mengatur properti ke nilai yang ditentukan saat DBNull dikembalikan dari sumber data, mengatur penyedia format yang ditentukan, dan menambahkan pengikatan ke koleksi.

AddCore(Binding)

Menambahkan pengikatan ke koleksi.

Clear()

Menghapus koleksi pengikatan apa pun.

ClearCore()

Menghapus pengikatan dalam koleksi.

CopyTo(Array, Int32)

Menyalin semua elemen satu dimensi Array saat ini ke satu dimensi Array yang ditentukan mulai dari indeks tujuan Array yang ditentukan.

(Diperoleh dari BaseCollection)
CreateObjRef(Type)

Membuat objek yang berisi semua informasi relevan yang diperlukan untuk menghasilkan proksi yang digunakan untuk berkomunikasi dengan objek jarak jauh.

(Diperoleh dari MarshalByRefObject)
Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetEnumerator()

Mendapatkan objek yang memungkinkan iterasi melalui anggota koleksi.

(Diperoleh dari BaseCollection)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetLifetimeService()
Kedaluwarsa.

Mengambil objek layanan seumur hidup saat ini yang mengontrol kebijakan seumur hidup untuk instans ini.

(Diperoleh dari MarshalByRefObject)
GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
InitializeLifetimeService()
Kedaluwarsa.

Mendapatkan objek layanan seumur hidup untuk mengontrol kebijakan seumur hidup untuk instans ini.

(Diperoleh dari MarshalByRefObject)
MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
MemberwiseClone(Boolean)

Membuat salinan dangkal objek saat ini MarshalByRefObject .

(Diperoleh dari MarshalByRefObject)
OnCollectionChanged(CollectionChangeEventArgs)

Memunculkan kejadian CollectionChanged.

(Diperoleh dari BindingsCollection)
OnCollectionChanging(CollectionChangeEventArgs)

Memunculkan kejadian CollectionChanging.

(Diperoleh dari BindingsCollection)
Remove(Binding)

Menghapus yang ditentukan Binding dari koleksi.

RemoveAt(Int32)

Menghapus pada Binding indeks yang ditentukan.

RemoveCore(Binding)

Menghapus pengikatan yang ditentukan dari koleksi.

ShouldSerializeMyAll()

Mendapatkan nilai yang menunjukkan apakah koleksi harus diserialisasikan.

(Diperoleh dari BindingsCollection)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Acara

CollectionChanged

Terjadi ketika koleksi telah berubah.

(Diperoleh dari BindingsCollection)
CollectionChanging

Terjadi ketika koleksi akan berubah.

(Diperoleh dari BindingsCollection)

Metode Ekstensi

Cast<TResult>(IEnumerable)

Mentransmisikan elemen dari ke IEnumerable jenis yang ditentukan.

OfType<TResult>(IEnumerable)

Memfilter elemen berdasarkan IEnumerable jenis yang ditentukan.

AsParallel(IEnumerable)

Mengaktifkan paralelisasi kueri.

AsQueryable(IEnumerable)

Mengonversi menjadi IEnumerableIQueryable.

Berlaku untuk