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

BindingManagerBase イベント


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

  名前 説明
パブリック イベント BindingComplete データ バインディング操作の完了時に発生します。
パブリック イベント CurrentChanged 現在バインドされている項目が変更されると発生します。
パブリック イベント CurrentItemChanged 現在バインドされている項目の状態が変更されたときに発生します。
パブリック イベント DataError Exception が BindingManagerBase によって処理された場合に発生します。
パブリック イベント PositionChanged Position プロパティの値が変更された後に発生します。
参照参照

関連項目

BindingManagerBase クラス
System.Windows.Forms 名前空間
BindingSource
BindingContext クラス
CurrencyManager
PropertyManager

BindingManagerBase クラス

同じデータ ソースおよび同じデータ メンバに結合された Binding オブジェクトをすべて管理します。このクラスは抽象クラスです。

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

Public MustInherit Class
 BindingManagerBase
Dim instance As BindingManagerBase
public abstract class BindingManagerBase
public ref class BindingManagerBase abstract
public abstract class BindingManagerBase
public abstract class BindingManagerBase
解説解説

BindingManagerBase は、同じデータ ソースにバインドされた Windows フォームのデータ バインド コントロールを同期できるようにします。データ ソースへのコントロールの単純バインディングの詳細については、Binding クラスのトピックを参照してください。たとえば、同じデータ ソースの異なる列にバインドされた 2 つの TextBox コントロールが配置されているフォームがあるとします。データ ソースは顧客の名前を格納している DataTable であり、列には姓と名が格納されているとします。同じ顧客に対して正しい姓と名を同時に表示するには、この 2 つのコントロールを同期させます。BindingManagerBase クラスから継承された CurrencyManager が、データ ソースの現在の項目へのポインタを維持することで、この同期を実行します。TextBox コントロールは、現在の項目にバインドされているため、同じ行の情報を表示します。現在の項目が変更されると、CurrencyManager が、すべての連結コントロールにデータを更新するように通知します。さらに、Position プロパティを設定して、コントロールが指す DataTable の行を指定できます。データ ソース内の行の数を確認するには、Count プロパティを使用します。

データ ソースが現在の項目のポインタを維持しているとは限らないため、CurrencyManager が必要です。たとえば、配列と ArrayList オブジェクトはデータ ソースになる場合がありますが、現在の項目を返すプロパティは持っていません。現在の項目を取得するには、Current プロパティを使用します。

PropertyManager も BindingManagerBase から継承され、データ ソース内の現在のオブジェクトのプロパティではなく、オブジェクトの現在のプロパティを維持するために使用されます。このため、PropertyManager に対する Position プロパティまたは Count プロパティの設定は無効です。

BindingManagerBase を作成するには、BindingContext クラスを使用します。この操作では、管理されているデータ ソースに応じて、CurrencyManager または PropertyManager のいずれかが返されます。

ソリューション プログラマは、コントロールを BindingSource コンポーネントに直接バインドすることをお勧めします。これは、データ ソースと、実際の対象データ ソースへのデータ コネクタの両方として機能します。BindingSource により、コントロールと対象の間の現在性の管理など、単純または複合データ バインディングが大幅に簡素化されます。

継承時の注意 BindingManagerBase から継承する場合は、抽象メンバである AddNew、Count、CancelCurrentEdit、Current、EndCurrentEdit、GetItemProperties、OnCurrentChanged、Position、RemoveAt、ResumeBinding、SuspendBinding、および UpdateIsBinding をオーバーライドする必要があります。

使用例使用例

BindingContext を使用して、特定のデータ ソースに対して BindingManagerBase を返すコード例を次に示します。この例では、モジュールの宣言セクションで myBindingManagerBase を宣言していることを前提にしています。さらに、この例では CurrentChanged イベントおよび PositionChanged イベントにイベント デリゲートを追加しています。最後に、この例には、Position プロパティをインクリメントまたはデクリメントし、Position をリストの最初または最後の行に設定する 4 つのメソッド (MoveNext、MovePrevious、MoveFirst、および MoveLast) が含まれています。リストの最後の行は、Count プロパティを使用して確認します。

Private Sub GetBindingManagerBase
   ' CustomersToOrders is the RelationName of a DataRelation.
   ' Therefore, the list maintained by the BindingManagerBase is the
   ' list of orders that belong to a specific customer in the
   ' DataTable named Customers, found in DataSet.
   myBindingManagerBase = Me.BindingContext(DataSet1, _
   "Customers.CustomersToOrders")

   ' Adds delegates to the CurrentChanged and PositionChanged events.
   AddHandler myBindingManagerBase.PositionChanged, _
   AddressOf BindingManagerBase_PositionChanged
   AddHandler myBindingManagerBase.CurrentChanged, _
   AddressOf BindingManagerBase_CurrentChanged
End Sub

Private Sub BindingManagerBase_PositionChanged
 _
(sender As Object, e As
 EventArgs)

   ' Prints the new Position of the BindingManagerBase.
   Console.Write("Position Changed: ")
   Console.WriteLine(CType(sender, BindingManagerBase).Position)
End Sub

Private Sub BindingManagerBase_CurrentChanged
 _
(sender As Object, e As
 EventArgs)

   ' Prints the new value of the current object.
   Console.Write("Current Changed: ")
   Console.WriteLine(CType(sender, BindingManagerBase).Current)
End Sub

Private Sub MoveNext
   ' Increments the Position property value by one.
   myBindingManagerBase.Position += 1
End Sub

Private Sub MovePrevious
   ' Decrements the Position property value by one.
   myBindingManagerBase.Position -= 1
End Sub

Private Sub MoveFirst
   ' Goes to the first row in the list.
   myBindingManagerBase.Position = 0
End Sub

Private Sub MoveLast
   ' Goes to the last row in the list.
   myBindingManagerBase.Position = _
   myBindingManagerBase.Count - 1
End Sub
private void GetBindingManagerBase()
{
   /* CustomersToOrders is the RelationName of a DataRelation. 
   Therefore, the list maintained by the BindingManagerBase is the
   list of orders that belong to a specific customer in the 
   DataTable named Customers, found in DataSet1. */
   myBindingManagerBase = 
   this.BindingContext[DataSet1, "Customers.CustomersToOrders"];

   // Adds delegates to the CurrentChanged and PositionChanged events.
   myBindingManagerBase.PositionChanged += 
   new EventHandler(BindingManagerBase_PositionChanged);
   myBindingManagerBase.CurrentChanged +=
   new EventHandler(BindingManagerBase_CurrentChanged);
}

private void BindingManagerBase_PositionChanged
(object sender, EventArgs e)
{
   // Prints the new Position of the BindingManagerBase.
   Console.Write("Position Changed: ");
   Console.WriteLine(((BindingManagerBase)sender).Position);
}

private void BindingManagerBase_CurrentChanged
(object sender, EventArgs e)
{
   // Prints the new value of the current object.
   Console.Write("Current Changed: ");
   Console.WriteLine(((BindingManagerBase)sender).Current);
}

private void MoveNext()
{
   // Increments the Position property value by one.
   myBindingManagerBase.Position += 1;
}

private void MovePrevious()
{
   // Decrements the Position property value by one.
   myBindingManagerBase.Position -= 1;
}

private void MoveFirst()
{
   // Goes to the first row in the list.
   myBindingManagerBase.Position = 0;
}

private void MoveLast()
{
   // Goes to the last row in the list.
   myBindingManagerBase.Position = 
   myBindingManagerBase.Count - 1;
}

void GetBindingManagerBase()
{
   
   /* CustomersToOrders is the RelationName of a DataRelation. 
      Therefore, the list maintained by the BindingManagerBase is the
      list of orders that belong to a specific customer in the
 
      DataTable named Customers, found in DataSet1. */
   myBindingManagerBase = this->BindingContext[DataSet1, "Customers.CustomersToOrders"];
   
   // Adds delegates to the CurrentChanged and PositionChanged events.
   myBindingManagerBase->PositionChanged += gcnew EventHandler( this,
 &Form1::BindingManagerBase_PositionChanged );
   myBindingManagerBase->CurrentChanged += gcnew EventHandler( this,
 &Form1::BindingManagerBase_CurrentChanged );
}

void BindingManagerBase_PositionChanged( Object^ sender, EventArgs^
 /*e*/ )
{
   
   // Prints the new Position of the BindingManagerBase.
   Console::Write( "Position Changed: " );
   Console::WriteLine( (dynamic_cast<BindingManagerBase^>(sender))->Position
 );
}

void BindingManagerBase_CurrentChanged( Object^ sender, EventArgs^
 /*e*/ )
{
   
   // Prints the new value of the current object.
   Console::Write( "Current Changed: " );
   Console::WriteLine( (dynamic_cast<BindingManagerBase^>(sender))->Current
 );
}

void MoveNext()
{
   
   // Increments the Position property value by one.
   myBindingManagerBase->Position = myBindingManagerBase->Position + 1;
}

void MovePrevious()
{
   
   // Decrements the Position property value by one.
   myBindingManagerBase->Position = myBindingManagerBase->Position - 1;
}

void MoveFirst()
{
   
   // Goes to the first row in the list.
   myBindingManagerBase->Position = 0;
}

void MoveLast()
{
   
   // Goes to the last row in the list.
   myBindingManagerBase->Position = myBindingManagerBase->Count - 1;
}

private void GetBindingManagerBase()
{
    /* CustomersToOrders is the RelationName of a DataRelation. 
       Therefore, the list maintained by the BindingManagerBase is the
       list of orders that belong to a specific customer in the
 
       DataTable named Customers, found in dataSet1. 
     */
    myBindingManagerBase = this.get_BindingContext().get_Item(dataSet1,
 
        "Customers.CustomersToOrders");

    // Adds delegates to the CurrentChanged and PositionChanged events.
    myBindingManagerBase.add_PositionChanged(new EventHandler
        (BindingManagerBase_PositionChanged));
    myBindingManagerBase.add_CurrentChanged(new EventHandler
        (BindingManagerBase_CurrentChanged));
} //GetBindingManagerBase

private void BindingManagerBase_PositionChanged(Object
 sender, EventArgs e)
{
    // Prints the new Position of the BindingManagerBase.
    Console.Write("Position Changed: ");
    Console.WriteLine(((BindingManagerBase)(sender)).get_Position());
} //BindingManagerBase_PositionChanged

private void BindingManagerBase_CurrentChanged(Object
 sender, EventArgs e)
{
    // Prints the new value of the current object.
    Console.Write("Current Changed: ");
    Console.WriteLine(((BindingManagerBase)(sender)).get_Current());
} //BindingManagerBase_CurrentChanged

private void MoveNext()
{
    // Increments the Position property value by one.
    myBindingManagerBase.set_Position(myBindingManagerBase.get_Position()
        + 1);
} //MoveNext

private void MovePrevious()
{
    // Decrements the Position property value by one.
    myBindingManagerBase.set_Position(myBindingManagerBase.get_Position()
        - 1);
} //MovePrevious

private void MoveFirst()
{
    // Goes to the first row in the list.
    myBindingManagerBase.set_Position(0);
} //MoveFirst

private void MoveLast()
{
    // Goes to the last row in the list.
    myBindingManagerBase.set_Position(myBindingManagerBase.get_Count() - 1);
} //MoveLast
継承階層継承階層
System.Object
  System.Windows.Forms.BindingManagerBase
     System.Windows.Forms.CurrencyManager
     System.Windows.Forms.PropertyManager
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingManagerBase メンバ
System.Windows.Forms 名前空間
BindingSource
BindingContext クラス
CurrencyManager
PropertyManager

BindingManagerBase コンストラクタ


BindingManagerBase フィールド


プロテクト フィールドプロテクト フィールド

  名前 説明
プロテクト フィールド onCurrentChangedHandler CurrentChanged イベントのイベント ハンドラを指定します。
プロテクト フィールド onPositionChangedHandler PositionChanged イベントのイベント ハンドラを指定します。
参照参照

関連項目

BindingManagerBase クラス
System.Windows.Forms 名前空間
BindingSource
BindingContext クラス
CurrencyManager
PropertyManager

BindingManagerBase プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Position 派生クラスでオーバーライドされると、このデータ ソースにバインドされたコントロールが指す、基になるリストでの位置を取得または設定します。
参照参照

関連項目

BindingManagerBase クラス
System.Windows.Forms 名前空間
BindingSource
BindingContext クラス
CurrencyManager
PropertyManager

BindingManagerBase メソッド


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

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド AddNew 派生クラスでオーバーライドされると、基になるリストに新しい項目を追加します。
パブリック メソッド CancelCurrentEdit 派生クラスでオーバーライドされると、現在の編集をキャンセルします。
パブリック メソッド EndCurrentEdit 派生クラスでオーバーライドされると、現在の編集を終了します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetItemProperties オーバーロードされます。 データ ソースのプロパティ記述子のリストを取得します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド RemoveAt 派生クラスでオーバーライドされると、基になるリストから指定されたインデックスに対応する行を削除します。
パブリック メソッド ResumeBinding 派生クラスでオーバーライドされると、データ連結を再開します。
パブリック メソッド SuspendBinding 派生クラスでオーバーライドされると、データ連結を中断します。
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

BindingManagerBase クラス
System.Windows.Forms 名前空間
BindingSource
BindingContext クラス
CurrencyManager
PropertyManager

BindingManagerBase メンバ

同じデータ ソースおよび同じデータ メンバに結合された Binding オブジェクトをすべて管理します。このクラスは抽象クラスです。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド BindingManagerBase BindingManagerBase クラスの新しいインスタンスを初期化します。
プロテクト フィールドプロテクト フィールド
  名前 説明
プロテクト フィールド onCurrentChangedHandler CurrentChanged イベントのイベント ハンドラを指定します。
プロテクト フィールド onPositionChangedHandler PositionChanged イベントのイベント ハンドラを指定します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Position 派生クラスでオーバーライドされると、このデータ ソースにバインドされたコントロールが指す、基になるリストでの位置を取得または設定します。
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド AddNew 派生クラスでオーバーライドされると、基になるリストに新しい項目を追加します。
パブリック メソッド CancelCurrentEdit 派生クラスでオーバーライドされると、現在の編集をキャンセルします。
パブリック メソッド EndCurrentEdit 派生クラスでオーバーライドされると、現在の編集を終了します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetItemProperties オーバーロードされます。 データ ソースのプロパティ記述子のリストを取得します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド RemoveAt 派生クラスでオーバーライドされると、基になるリストから指定されたインデックスに対応する行を削除します。
パブリック メソッド ResumeBinding 派生クラスでオーバーライドされると、データ連結を再開します。
パブリック メソッド SuspendBinding 派生クラスでオーバーライドされると、データ連結を中断します。
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント BindingComplete データ バインディング操作の完了時に発生します。
パブリック イベント CurrentChanged 現在バインドされている項目が変更されると発生します。
パブリック イベント CurrentItemChanged 現在バインドされている項目の状態が変更されたときに発生します。
パブリック イベント DataError Exception が BindingManagerBase によって処理された場合に発生します。
パブリック イベント PositionChanged Position プロパティの値が変更された後に発生します。
参照参照

関連項目

BindingManagerBase クラス
System.Windows.Forms 名前空間
BindingSource
BindingContext クラス
CurrencyManager
PropertyManager



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「BindingManagerBase」の関連用語

BindingManagerBaseのお隣キーワード

   

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



BindingManagerBaseのページの著作権

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

©2026 GRAS Group, Inc.RSS