BindingsCollectionとは? わかりやすく解説

BindingsCollection イベント


パブリック イベントパブリック イベント

参照参照

関連項目

BindingsCollection クラス
System.Windows.Forms 名前空間
CurrencyManager

BindingsCollection クラス

コントロールBinding オブジェクトコレクション表します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class BindingsCollection
    Inherits BaseCollection
Dim instance As BindingsCollection
public class BindingsCollection : BaseCollection
public ref class BindingsCollection : public
 BaseCollection
public class BindingsCollection extends BaseCollection
public class BindingsCollection extends
 BaseCollection
解説解説
使用例使用例

TextBox コントロールText プロパティデータベース内のフィールドバインドする例を次に示します

Private Sub BindTextBoxControl()
   Dim myDataSet As New
 DataSet()
   ' Insert code to populate the DataSet with tables, columns, and data.

   ' Creates a new Binding object. 
   Dim myBinding As New
 Binding("Text", myDataSet, _
   "customers.custToOrders.OrderAmount")
   
   ' Adds event delegates for the Parse and Format events.
   AddHandler myBinding.Parse, AddressOf CurrencyToDecimal
   AddHandler myBinding.Format, AddressOf DecimalToCurrency
     
   ' Adds the new Binding to the BindingsCollection.
   text1.DataBindings.Add(myBinding)
End Sub 
    
Private Sub DecimalToCurrency(sender As
 Object, _
   cevent As ConvertEventArgs)
   ' This method is the Format event handler. Whenever the
   ' control displays a new value, the value is converted from
   ' its native Decimal type to a string. The ToString method
   ' then formats the value as a Currency, by using the
   ' formatting character "c". 
   cevent.Value = CDec(cevent.Value).ToString("c")
End Sub 
    
Private Sub CurrencyToDecimal(sender As
 Object, _
cevent As ConvertEventArgs)
   ' This method is the Parse event handler. The Parse event
   ' occurs whenever the displayed value changes. The static
   ' Parse method of the Decimal structure converts the 
   ' string back to its native Decimal type. 
   cevent.Value = Decimal.Parse(cevent.Value.ToString(), _
   NumberStyles.Currency, nothing)
   End Sub 
private void BindTextBoxControl()
{
   DataSet myDataSet = new DataSet();
   /* Insert code to populate the DataSet with tables, 
   columns, and data. */

   // Creates a new Binding object. 
   Binding myBinding = new Binding
   ("Text", myDataSet, "customers.custToOrders.OrderAmount");

   // Adds event delegates for the Parse and Format events.
   myBinding.Parse += new ConvertEventHandler(CurrencyToDecimal);
   myBinding.Format += new ConvertEventHandler(DecimalToCurrency);

   // Adds the new Binding to the BindingsCollection.
   text1.DataBindings.Add(myBinding);
}

private void DecimalToCurrency(object sender,
 
   ConvertEventArgs cevent)
{
   /* This method is the Format event handler. Whenever the 
   control displays a new value, the value is converted from 
   its native Decimal type to a string. The ToString method 
   then formats the value as a Currency, by using the 
   formatting character "c". */
   cevent.Value = ((decimal) cevent.Value).ToString("c");
}

private void CurrencyToDecimal(object sender,
 
   ConvertEventArgs cevent)
{   
   /* This method is the Parse event handler. The Parse event 
   occurs whenever the displayed value changes. The static 
   Parse method of the Decimal structure converts the 
   string back to its native Decimal type. */
   cevent.Value = Decimal.Parse(cevent.Value.ToString(),
   NumberStyles.Currency, null);
}

private:
   void BindTextBoxControl()
   {
      DataSet^ myDataSet = gcnew DataSet;
      /* Insert code to populate the DataSet with tables, 
      columns, and data. */

      // Creates a new Binding object. 
      Binding^ myBinding = gcnew Binding(
         "Text",myDataSet,"customers.custToOrders.OrderAmount"
 );
      
      // Adds event delegates for the Parse and Format events.
      myBinding->Parse += gcnew ConvertEventHandler( this,
 &Form1::CurrencyToDecimal );
      myBinding->Format += gcnew ConvertEventHandler( this,
 &Form1::DecimalToCurrency );
      
      // Adds the new Binding to the BindingsCollection.
      text1->DataBindings->Add( myBinding );
   }

   void DecimalToCurrency( Object^ /*sender*/, ConvertEventArgs^
 cevent )
   {
      /* This method is the Format event handler. Whenever the 
      control displays a new value, the value is converted from
 
      its native Decimal type to a string. The ToString method
 
      then formats the value as a Currency, by using the 
      formatting character "c". */
      cevent->Value = safe_cast<Decimal ^>(cevent->Value)->ToString(
  "c" );
   }

   void CurrencyToDecimal( Object^ /*sender*/, ConvertEventArgs^
 cevent )
   {
      /* This method is the Parse event handler. The Parse event 
      occurs whenever the displayed value changes. The static
 
      Parse method of the Decimal structure converts the 
      string back to its native Decimal type. */
      cevent->Value = Decimal::Parse( cevent->Value->ToString(),
         NumberStyles::Currency, nullptr );
   }
private void BindTextBoxControl()
{
    DataSet myDataSet = new DataSet();
    /* Insert code to populate the DataSet with tables, 
       columns, and data. 
     */

    // Creates a new Binding object. 
    Binding myBinding = new Binding("Text", myDataSet
,
        "customers.custToOrders.OrderAmount");

    // Adds event delegates for the Parse and Format events.
    myBinding.add_Parse(new ConvertEventHandler(CurrencyToDecimal));
    myBinding.add_Format(new ConvertEventHandler(DecimalToCurrency));

    // Adds the new Binding to the BindingsCollection.
    text1.get_DataBindings().Add(myBinding);
} //BindTextBoxControl

private void DecimalToCurrency(Object sender,
 ConvertEventArgs cevent)
{
    /* This method is the Format event handler. Whenever the 
       control displays a new value, the value is converted from
 
       its native Decimal type to a string. The ToString method
 
       then formats the value as a Currency, by using the 
       formatting character "c". 
     */
    cevent.set_Value(((System.Decimal)(cevent.get_Value())).ToString("c"));
} //DecimalToCurrency

private void CurrencyToDecimal(Object sender,
 ConvertEventArgs cevent)
{
    /* This method is the Parse event handler. The Parse event 
       occurs whenever the displayed value changes. The static
 
       Parse method of the Decimal structure converts the 
       string back to its native Decimal type. 
     */
    cevent.set_Value(Decimal.Parse(cevent.get_Value().ToString(),
        NumberStyles.Currency, null));
} //CurrencyToDecimal
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.Windows.Forms.BaseCollection
      System.Windows.Forms.BindingsCollection
         System.Windows.Forms.ControlBindingsCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingsCollection メンバ
System.Windows.Forms 名前空間
CurrencyManager

BindingsCollection プロパティ


BindingsCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド 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 から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

BindingsCollection クラス
System.Windows.Forms 名前空間
CurrencyManager

BindingsCollection メンバ

コントロールBinding オブジェクトコレクション表します

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


パブリック プロパティパブリック プロパティ
( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Count オーバーライドされますコレクション内のバインディング合計数を取得します
パブリック プロパティ IsReadOnly  コレクション読み取り専用かどうかを示す値を取得します。(BaseCollection から継承されます。)
パブリック プロパティ IsSynchronized  ICollection へのアクセス同期がとられているかどうかを示す値を取得します。(BaseCollection から継承されます。)
パブリック プロパティ SyncRoot  BaseCollection へのアクセス同期するために使用できるオブジェクト取得します。(BaseCollection から継承されます。)
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド 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 から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
参照参照

関連項目

BindingsCollection クラス
System.Windows.Forms 名前空間
CurrencyManager



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「BindingsCollection」の関連用語

BindingsCollectionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BindingsCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS