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

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 つメソッド (MoveNextMovePreviousMoveFirst、および 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


このページでは「.NET Framework クラス ライブラリ リファレンス」からBindingManagerBase クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBindingManagerBase クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBindingManagerBase クラス を検索

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

辞書ショートカット

すべての辞書の索引

「BindingManagerBase クラス」の関連用語

BindingManagerBase クラスのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS