ControlBindingsCollection クラス

定義

コントロールのデータ バインドのコレクションを表します。

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
継承
属性

次のコード例では、5 つのコントロール (4 つのTextBoxコントロールとコントロール) の にオブジェクトControlBindingsCollectionDateTimePicker追加Bindingします。 ControlBindingsCollection には、DataBindings クラスの Control プロパティを使用してアクセスします。

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

注釈

単純なデータ バインディングは、 にオブジェクトをControlBindingsCollection追加Bindingすることによって実現されます。 クラスから継承するすべてのオブジェクトは、 Control プロパティを介して にControlBindingsCollectionDataBindingsアクセスできます。 データ バインディングをサポートする Windows コントロールの一覧については、 クラスを Binding 参照してください。

にはControlBindingsCollection、 などのAddClearRemove標準的なコレクション メソッドが含まれています。

が属するコントロールを ControlBindingsCollection 取得するには、 プロパティを Control 使用します。

コンストラクター

ControlBindingsCollection(IBindableComponent)

指定したバインドできるコントロールを使用して ControlBindingsCollection クラスの新しいインスタンスを初期化します。

プロパティ

BindableComponent

バインディング コレクションが属する IBindableComponent を取得します。

Control

コレクションが属するコントロールを取得します。

Count

コレクション内のバインディングの合計数を取得します。

(継承元 BindingsCollection)
DefaultDataSourceUpdateMode

コレクションに含まれる Binding の既定の DataSourceUpdateMode を取得または設定します。

IsReadOnly

コレクションが読み取り専用かどうかを示す値を取得します。

(継承元 BaseCollection)
IsSynchronized

ICollection へのアクセスの同期がとられているかどうかを示す値を取得します。

(継承元 BaseCollection)
Item[Int32]

指定されたインデックス位置にある Binding を取得します。

(継承元 BindingsCollection)
Item[String]

コントロールのプロパティ名で指定した Binding を取得します。

List

コレクション内のバインディングをオブジェクトとして取得します。

(継承元 BindingsCollection)
SyncRoot

BaseCollection へのアクセスを同期するために使用できるオブジェクトを取得します。

(継承元 BaseCollection)

メソッド

Add(Binding)

指定された Binding をコレクションに追加します。

Add(String, Object, String)

指定したコントロール プロパティ名、データ ソース、およびデータ メンバーを使用して Binding を作成し、コレクションに追加します。

Add(String, Object, String, Boolean)

指定したコントロール プロパティ名、データ ソース、データ メンバー、および書式指定を有効にするかどうかに関する情報を使用してバインディングを作成し、コレクションに追加します。

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

指定したコントロール プロパティを、指定したデータ ソースの指定したデータ メンバーにバインドするバインディングを作成します。さらに、オプションで書式指定を有効にし、指定した更新設定に基づいてデータ ソースに値を反映し、バインディングをコレクションに追加します。

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

指定したコントロール プロパティを、指定したデータ ソースの指定したデータ メンバーにバインドするバインディングを作成します。さらに、オプションで書式指定を有効にし、指定した更新設定に基づいてデータ ソースに値を反映し、データ ソースから DBNull が返されたときにプロパティに指定した値を設定し、バインディングをコレクションに追加します。

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

指定したコントロール プロパティを、指定したデータ ソースの指定したデータ メンバーにバインドするバインディングを作成します。さらに、オプションで指定した書式指定文字列を使用して書式指定を有効にし、指定した更新設定に基づいてデータ ソースに値を反映し、データ ソースから DBNull が返されたときにプロパティに指定した値を設定し、バインディングをコレクションに追加します。

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

指定したコントロール プロパティを、指定したデータ ソースの指定したデータ メンバーにバインドするバインディングを作成します。さらに、オプションで指定した書式指定文字列を使用して書式指定を有効にし、指定した更新設定に基づいてデータ ソースに値を反映し、データ ソースから DBNull が返されたときにプロパティに指定した値を設定し、指定した書式プロバイダーを設定し、バインディングをコレクションに追加します。

AddCore(Binding)

バインディングをコレクションに追加します。

Clear()

バインディングのコレクションを消去します。

ClearCore()

コレクション内のバインディングを消去します。

CopyTo(Array, Int32)

現在の 1 次元 Array のすべての要素を、指定した 1 次元 ArrayArray の指定したコピー先インデックスを開始位置としてコピーします。

(継承元 BaseCollection)
CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetEnumerator()

コレクションのメンバーを反復処理できるオブジェクトを取得します。

(継承元 BaseCollection)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetLifetimeService()
古い.

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeLifetimeService()
古い.

このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
OnCollectionChanged(CollectionChangeEventArgs)

CollectionChanged イベントを発生させます。

(継承元 BindingsCollection)
OnCollectionChanging(CollectionChangeEventArgs)

CollectionChanging イベントを発生させます。

(継承元 BindingsCollection)
Remove(Binding)

指定した Binding をコレクションから削除します。

RemoveAt(Int32)

指定したインデックスの Binding を削除します。

RemoveCore(Binding)

指定したバインディングをコレクションから削除します。

ShouldSerializeMyAll()

コレクションをシリアル化する必要があるかどうかを示す値を取得します。

(継承元 BindingsCollection)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

イベント

CollectionChanged

コレクションが変更されたときに発生します。

(継承元 BindingsCollection)
CollectionChanging

コレクションが変更される直前に発生します。

(継承元 BindingsCollection)

拡張メソッド

Cast<TResult>(IEnumerable)

IEnumerable の要素を、指定した型にキャストします。

OfType<TResult>(IEnumerable)

指定された型に基づいて IEnumerable の要素をフィルター処理します。

AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryable に変換します。

適用対象