ControlBindingsCollection イベント

名前 | 説明 | |
---|---|---|
![]() | CollectionChanged | コレクションが変更された場合に発生します。 ( BindingsCollection から継承されます。) |
![]() | CollectionChanging | コレクションが変更される直前に発生します。 ( BindingsCollection から継承されます。) |

ControlBindingsCollection クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


単純なデータ連結は、Binding オブジェクトを ControlBindingsCollection に追加することによって実行されます。Control クラスから継承される任意のオブジェクトは、DataBindings プロパティを使用して ControlBindingsCollection にアクセスできます。データ連結をサポートする Windows コントロールの一覧については、Binding クラスのトピックを参照してください。
ControlBindingsCollection は、Add、Clear、Remove など、標準のコレクションのメソッドを格納しています。
ControlBindingsCollection が属しているコントロールを取得するには、Control プロパティを使用します。

5 つのコントロール (4 つの TextBox コントロールと 1 つの DateTimePicker コントロール) の ControlBindingsCollection に、Binding オブジェクトを追加するコード例を次に示します。ControlBindingsCollection には、Control クラスの DataBindings プロパティを使用してアクセスします。
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
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: 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.get_DataBindings(). Add(new Binding("Text", ds, "customers.custName")); textBox2.get_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.get_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.add_Parse(new ConvertEventHandler(CurrencyStringToDecimal)); b.add_Format(new ConvertEventHandler(DecimalToCurrencyString)); textBox3.get_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.get_DataBindings().Add("Text", dateTimePicker1, "Value"); // Get the BindingManagerBase for the textBox4 Binding. BindingManagerBase bmText = this.get_BindingContext().get_Item(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.get_Count()); // Get the BindingManagerBase for the Customers table. bmCustomers = this.get_BindingContext().get_Item(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.get_Count()); /* Get the BindingManagerBase for the Orders of the current customer using a navigation path: TableName.RelationName. */ bmOrders = this.get_BindingContext().get_Item(ds, "customers.CustToOrders"); } //BindControls

System.MarshalByRefObject
System.Windows.Forms.BaseCollection
System.Windows.Forms.BindingsCollection
System.Windows.Forms.ControlBindingsCollection


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ControlBindingsCollection コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ControlBindingsCollection プロパティ

名前 | 説明 | |
---|---|---|
![]() | Count | コレクション内のバインディングの合計数を取得します。 ( BindingsCollection から継承されます。) |
![]() | IsReadOnly | コレクションが読み取り専用かどうかを示す値を取得します。 ( BaseCollection から継承されます。) |
![]() | IsSynchronized | ICollection へのアクセスの同期がとられているかどうかを示す値を取得します。 ( BaseCollection から継承されます。) |
![]() | Item | オーバーロードされます。 指定した Binding をコレクションから取得します。 |
![]() | SyncRoot | BaseCollection へのアクセスを同期するために使用できるオブジェクトを取得します。 ( BaseCollection から継承されます。) |


ControlBindingsCollection メソッド


名前 | 説明 | |
---|---|---|
![]() | AddCore | オーバーライドされます。 バインディングをコレクションに追加します。 |
![]() | ClearCore | オーバーライドされます。 コレクションに含まれるすべてのバインディングを削除します。 |
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
![]() | OnCollectionChanged | CollectionChanged イベントを発生させます。 ( BindingsCollection から継承されます。) |
![]() | OnCollectionChanging | CollectionChanging イベントを発生させます。 ( BindingsCollection から継承されます。) |
![]() | RemoveCore | オーバーライドされます。 指定したバインディングをコレクションから削除します。 |
![]() | ShouldSerializeMyAll | コレクションをシリアル化する必要があるかどうかを示す値を取得します。 ( BindingsCollection から継承されます。) |

ControlBindingsCollection メンバ
ControlBindingsCollection データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | ControlBindingsCollection | 指定したバインドできるコントロールを使用して ControlBindingsCollection クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() | Count | コレクション内のバインディングの合計数を取得します。(BindingsCollection から継承されます。) |
![]() | IsReadOnly | コレクションが読み取り専用かどうかを示す値を取得します。(BaseCollection から継承されます。) |
![]() | IsSynchronized | ICollection へのアクセスの同期がとられているかどうかを示す値を取得します。(BaseCollection から継承されます。) |
![]() | Item | オーバーロードされます。 指定した Binding をコレクションから取得します。 |
![]() | SyncRoot | BaseCollection へのアクセスを同期するために使用できるオブジェクトを取得します。(BaseCollection から継承されます。) |


名前 | 説明 | |
---|---|---|
![]() | Add | オーバーロードされます。 Binding をコレクションに追加します。 |
![]() | Clear | バインディングのコレクションを消去します。 |
![]() | CopyTo | 指定したコピー先の Array インデックスを開始位置として、現在の 1 次元 Array のすべての要素を指定した 1 次元 Array にコピーします。 (BaseCollection から継承されます。) |
![]() | CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。) |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetEnumerator | コレクションのメンバを反復処理できるオブジェクトを取得します。 (BaseCollection から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | InitializeLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Remove | 指定した Binding をコレクションから削除します。 |
![]() | RemoveAt | 指定したインデックスの Binding を削除します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | AddCore | オーバーライドされます。 バインディングをコレクションに追加します。 |
![]() | ClearCore | オーバーライドされます。 コレクションに含まれるすべてのバインディングを削除します。 |
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
![]() | OnCollectionChanged | CollectionChanged イベントを発生させます。 (BindingsCollection から継承されます。) |
![]() | OnCollectionChanging | CollectionChanging イベントを発生させます。 (BindingsCollection から継承されます。) |
![]() | RemoveCore | オーバーライドされます。 指定したバインディングをコレクションから削除します。 |
![]() | ShouldSerializeMyAll | コレクションをシリアル化する必要があるかどうかを示す値を取得します。 (BindingsCollection から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | CollectionChanged | コレクションが変更された場合に発生します。(BindingsCollection から継承されます。) |
![]() | CollectionChanging | コレクションが変更される直前に発生します。(BindingsCollection から継承されます。) |

Weblioに収録されているすべての辞書からControlBindingsCollectionを検索する場合は、下記のリンクをクリックしてください。

- ControlBindingsCollectionのページへのリンク