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

BindingContext イベント


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

  名前 説明
パブリック イベント CollectionChanged 処理されると、常に NotImplementedException が発生します。
参照参照

関連項目

BindingContext クラス
System.Windows.Forms 名前空間
BindingManagerBase
Binding クラス
BindingsCollection

BindingContext クラス

Control クラスから継承されるすべてのオブジェクトについて、BindingManagerBase オブジェクトのコレクションを管理します。

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

Public Class BindingContext
    Implements ICollection, IEnumerable
Dim instance As BindingContext
public class BindingContext : ICollection,
 IEnumerable
public ref class BindingContext : ICollection,
 IEnumerable
public class BindingContext implements ICollection,
 IEnumerable
public class BindingContext implements ICollection,
 IEnumerable
解説解説

各 Windows フォームには、そのフォームの BindingManagerBase オブジェクトを管理する BindingContext オブジェクトが少なくとも 1 つ存在します。BindingManagerBase クラスは抽象クラスであるため、Item プロパティの戻り値の型は、CurrencyManager と PropertyManager のどちらかになります。データ ソースが、オブジェクトのリストではなく単一のプロパティだけを返すことのできるオブジェクトの場合は、Type は PropertyManager です。たとえば、データ ソースとして TextBox を指定すると、PropertyManager が返されます。一方、データ ソースが IList または IBindingList を実装するオブジェクトの場合は、CurrencyManager が返されます。

Windows フォーム上のデータ ソースには、それぞれ、CurrencyManager または PropertyManager が 1 つ存在します。1 つの Windows フォームに複数のデータ ソースが関連付けられていることも考えられます。その場合は、BindingContext を使用することで、データ ソースに関連付けられた特定の CurrencyManager を取得できます。

メモメモ

Item プロパティを使用すると、まだ存在しない場合は、BindingContext によって新しい BindingManagerBase が作成されます。この処理によって、リターン オブジェクトが目的のリスト (またはすべてのリスト) を管理できなくなるなどの混乱が生じる場合があります。無効な BindingManagerBase が返されないようにするには、Contains メソッドを使用して、目的の BindingManagerBase が既に存在するかどうかを確認します。

GroupBox、Panel、TabControl などのコンテナ コントロールを使用してデータ連結コントロールを格納する場合は、コンテナ コントロールおよびコンテナ内にあるコントロールだけで構成された BindingContext を作成できます。これにより、フォームの各部分をフォーム自体の BindingManagerBase オブジェクトで管理できます。同じデータ ソースに対して複数の BindingManagerBase オブジェクトを作成する場合の詳細については、BindingContext コンストラクタのトピックを参照してください。

TextBox コントロールをフォームに追加し、データセット内のテーブルの列にバインドした場合、バインドされたコントロールは、そのフォームの BindingContext と通信します。次に、BindingContext が、データの関連付けを追跡する特定の CurrencyManager と通信します。CurrencyManager の Position プロパティを照会すると、対応する TextBox コントロールのバインディングについて、現在のレコードが報告されます。次のコード例では、TextBox コントロールが、フォームの BindingContext によって、dataSet1 データセットに格納された Customers テーブルの FirstName 列とバインドされます。

TextBox1.DataBindings.Add("Text", dataSet1, "Customers.FirstName")

textBox1.DataBindings.Add("Text", dataSet1, "Customers.FirstName");

textBox1->DataBindings->Add("Text", dataSet1, "Customers.FirstName");

2 つ目の TextBox コントロール (TextBox2) をフォームに追加して、それを同じデータセットに格納された Customers テーブルの LastName 列とバインドできます。BindingContext によって 1 つ目のバインディング (TextBox1 と Customers.FirstName) が追跡されるため、両方のテキスト ボックスが同じデータセット (DataSet1) にバインドされていても、同じ CurrencyManager が使用されます。

TextBox2.DataBindings.Add("Text", dataSet1, "Customers.LastName")

textBox2.DataBindings.Add("Text", dataSet1, "Customers.LastName");

textBox2->DataBindings->Add("Text", dataSet1, "Customers.LastName");

TextBox2 を異なるデータセットにバインドする場合は、BindingContext が CurrencyManager をもう 1 つ作成して管理します。

DataSource プロパティと DisplayMember プロパティの設定方法には一貫性を持たせることが大切です。そうしないと、BindingContext によって、同じデータセットに対して複数の CurrencyManager が作成され、エラーが発生します。これらのプロパティおよび関連付けられた BindingContext オブジェクトを設定する方法を、次のコード例にいくつか示します。これらのプロパティは、コード全体を通じて一貫性が保たれている限り、次のいずれの方法を使用しても設定できます。

ComboBox1.DataSource = DataSet1
ComboBox1.DisplayMember = "Customers.FirstName"
Me.BindingContext(dataSet1, "Customers").Position
 = 1

comboBox1.DataSource = DataSet1;
comboBox1.DisplayMember = "Customers.FirstName";
this.BindingContext[dataSet1, "Customers"].Position
 = 1;

comboBox1->DataSource = dataSet1;
comboBox1->DisplayMember = "Customers.FirstName";
this->BindingContext->get_Item(dataSet1, "Customers")->Position
 = 1;

ComboBox1.DataSource = DataSet1.Customers
ComboBox1.DisplayMember = "FirstName"
Me.BindingContext(dataSet1.Customers).Position = 1

comboBox1.DataSource = DataSet1.Customers;
comboBox1.DisplayMember = "FirstName";
this.BindingContext[dataSet1.Customers].Position = 1;

comboBox1->DataSource = dataSet1->Customers;
comboBox1->DisplayMember = "FirstName";
this->BindingContext->get_Item(dataSet1->Customers)->Position
 = 1;
メモメモ

Windows フォーム アプリケーションにおけるバインディングは、ほとんどの場合、BindingSource を通じて行われます。BindingSource コンポーネントは、CurrencyManager をカプセル化し、CurrencyManager のプログラミング インターフェイスを公開します。バインディングに BindingSource を使用する場合、"現在性" (つまり、Position) を操作するときには、BindingContext ではなく、BindingSource によって公開されたメンバを使用する必要があります。

使用例使用例

4 つの Binding オブジェクトを作成して、5 つのコントロール (1 つの DateTimePicker コントロールと 4 つの TextBox コントロール) を複数のデータ ソースにバインドするコード例を次に示します。さらに、BindingContext を使用して、各データ ソースの BindingManagerBase を取得します。

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 string 
   '   "TableName.ColumnName".
   text1.DataBindings.Add(New Binding _
      ("Text", ds, "customers.custName"))
   text2.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 
   '   TableName.RelationName.ColumnName string.
   DateTimePicker1.DataBindings.Add(New Binding _
      ("Value", ds, "customers.CustToOrders.OrderDate"))

   ' Add event delegates for the Parse and Format events to a 
   '   new 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 Binding = New
 Binding _
      ("Text", ds, "customers.custToOrders.OrderAmount")
   AddHandler b.Parse,  New ConvertEventHandler(AddressOf
 CurrencyStringToDecimal)      
   AddHandler b.Format, New ConvertEventHandler(AddressOf
 DecimalToCurrencyString)
   text3.DataBindings.Add(b)

   ' Get the BindingManagerBase for the Customers table.
   bmCustomers = Me.BindingContext(ds, "Customers")

   ' Get the BindingManagerBase for the Orders table using the 
   '   RelationName.
   bmOrders = Me.BindingContext(ds, "customers.CustToOrders")

   ' Bind the fourth TextBox control's Text property to the
   ' third control's Text property.
   text4.DataBindings.Add("Text", text3, "Text")

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 a navigation path in the form:
 
      "TableName.ColumnName". */
   text1.DataBindings.Add(new Binding
   ("Text", ds, "customers.custName"));
   text2.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 string. */
   DateTimePicker1.DataBindings.Add(new 
   Binding("Value", ds, "customers.CustToOrders.OrderDate"));

   /* Add event delegates for the Parse and Format events to a
 
      new 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);
   text3.DataBindings.Add(b);

   // Get the BindingManagerBase for the Customers table. 
   bmCustomers = this.BindingContext [ds, "Customers"];

   /* Get the BindingManagerBase for the Orders table using
 the 
      RelationName. */ 
   bmOrders = this.BindingContext[ds, "customers.CustToOrders"];

   /* Bind the fourth TextBox control's Text property to the
   third control's Text property. */
   text4.DataBindings.Add("Text", text3, "Text");
}

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 a navigation path in the form:
 
         "TableName.ColumnName". */
   text1->DataBindings->Add( gcnew Binding( "Text",ds,"customers.custName"
 ) );
   text2->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 string. */
   DateTimePicker1->DataBindings->Add( gcnew Binding( "Value",ds,"customers.CustToOrders.OrderDate"
 ) );

   /* Add event delegates for the Parse and Format events to a
 
         new 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
 );
   text3->DataBindings->Add( b );

   // Get the BindingManagerBase for the Customers table. 
   bmCustomers = this->BindingContext[ ds,"Customers"
 ];

   /* Get the BindingManagerBase for the Orders table using
 the 
         RelationName. */
   bmOrders = this->BindingContext[ds, "customers.CustToOrders"];

   /* Bind the fourth TextBox control's Text property to the
      third control's Text property. */
   text4->DataBindings->Add( "Text", text3, "Text" );
}
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 a navigation path in the form:
 
       "TableName.ColumnName". 
     */
    text1.get_DataBindings().Add(new Binding("Text",
 ds, 
        "customers.custName"));
    text2.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 string. 
     */
    dateTimePicker1.get_DataBindings().Add(new Binding("Value",
 ds, 
        "customers.CustToOrders.OrderDate"));

    /* Add event delegates for the Parse and Format events to a
 
       new 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));
    text3.get_DataBindings().Add(b);

    // Get the BindingManagerBase for the Customers table. 
    bmCustomers = this.get_BindingContext().get_Item(ds, "Customers");

    /* Get the BindingManagerBase for the Orders table using
 the 
       RelationName. 
     */
    bmOrders = this.get_BindingContext().get_Item(ds, 
        "customers.CustToOrders");

    /* Bind the fourth TextBox control's Text property to the
       third control's Text property. 
     */
    text4.get_DataBindings().Add("Text", text3, "Text");
} //BindControls
  protected function 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 string 
        "TableName.ColumnName". */
     text1.DataBindings.Add(new Binding
     ("Text", ds, "customers.custName"));
     text2.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 
        TableName.RelationName.ColumnName string. */
     DateTimePicker1.DataBindings.Add(new 
     Binding("Value", ds, "customers.CustToOrders.OrderDate"));

     /* Add event delegates for the Parse and Format events to a
 
        new 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. */
     var b : Binding = new Binding
        ("Text", ds, "customers.custToOrders.OrderAmount");
     b.add_Parse(CurrencyStringToDecimal);
     b.add_Format(DecimalToCurrencyString);
     text3.DataBindings.Add(b);

     // Get the BindingManagerBase for the Customers table. 
     bmCustomers = this.BindingContext [ds, "Customers"];

     /* Get the BindingManagerBase for the Orders table using
 the 
        RelationName. */ 
     bmOrders = this.BindingContext[ds, "customers.CustToOrders"];
  }

  private function DecimalToCurrencyString(sender,
 cevent : 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". */

     // We can only convert to string type. 
     if(cevent.DesiredType != String.GetType()) return;

     cevent.Value = (Decimal(cevent.Value)).ToString("c");
  }

  private function CurrencyStringToDecimal(sender,
 cevent : ConvertEventArgs)
  {   
     /* This method is the Parse event-handler. The Parse event 
        occurs whenever the displayed value changes. The static
 
        ToDecimal method of the Convert class converts the 
        value back to its native Decimal type. */

     // Can only convert to Decimal type.
     if(cevent.DesiredType != Decimal.GetType()) return;

     cevent.Value = Decimal.Parse(cevent.Value.ToString(),
         NumberStyles.Currency, null);

     /* To see that no precision is lost, print the unformatted 
        value. For example, changing a value to "10.0001" 
        causes the control to display "10.00", but the 
        unformatted value remains "10.0001". */
     Console.WriteLine(cevent.Value);
  }

  protected function button1_Click(sender,
 e : System.EventArgs)
  {
     // Go to the previous item in the Customer list.
     bmCustomers.Position -= 1;
  }

  protected function button2_Click(sender,
 e : System.EventArgs)
  {
     // Go to the next item in the Customer list.
     bmCustomers.Position += 1;
  }
   
  protected function button3_Click(sender,
 e : System.EventArgs)
  {
     // Go to the previous item in the Orders list.
     bmOrders.Position-=1;
  }

  protected function button4_Click(sender,
 e : System.EventArgs)
  {
     // Go to the next item in the Orders list.
     bmOrders.Position+=1;
  }

  // Create a DataSet with two tables and populate it.
  private function MakeDataSet()
  {
     // Create a DataSet.
     ds = new DataSet("myDataSet");
     
     // Create two DataTables.
     var tCust : DataTable = new DataTable("Customers");
     var tOrders : DataTable= new DataTable("Orders");

     // Create two columns, and add them to the first table.
     var cCustID : DataColumn = new DataColumn("CustID",
 Int32);
     var cCustName : DataColumn = new DataColumn("CustName");
     tCust.Columns.Add(cCustID);
     tCust.Columns.Add(cCustName);

     // Create three columns, and add them to the second table.
     var cID : DataColumn  = 
        new DataColumn("CustID", Int32);
     var cOrderDate : DataColumn  = 
        new DataColumn("orderDate", DateTime);
     var cOrderAmount : DataColumn = 
        new DataColumn("OrderAmount", Decimal);
     tOrders.Columns.Add(cOrderAmount);
     tOrders.Columns.Add(cID);
     tOrders.Columns.Add(cOrderDate);

     // Add the tables to the DataSet.
     ds.Tables.Add(tCust);
     ds.Tables.Add(tOrders);

     // Create a DataRelation, and add it to the DataSet.
     var dr : DataRelation = new DataRelation
     ("custToOrders", cCustID , cID);
     ds.Relations.Add(dr);
  
     /* Populate the tables. For each customer and order, 
        create need two DataRow variables. */
     var newRow1 : DataRow;
     var newRow2 : DataRow;

     // Create three customers in the Customers Table.
     for(var i : int = 1;
 i < 4; i++)
     {
        newRow1 = tCust.NewRow();
        newRow1["custID"] = i;
        // Add the row to the Customers table.
        tCust.Rows.Add(newRow1);
     }
     // Give each customer a distinct name.
     tCust.Rows[0]["custName"] = "Alpha";
     tCust.Rows[1]["custName"] = "Beta";
     tCust.Rows[2]["custName"] = "Omega";
     
     // For each customer, create five rows in the Orders table.
     for(var j : int = 1;
 j < 4; j++)
     {
        for(var k : int
 = 1; k < 6; k++)
        {
           newRow2 = tOrders.NewRow();
           newRow2["CustID"]= j;
           newRow2["orderDate"]= new DateTime(2001,
 j, k * 2);
           newRow2["OrderAmount"] = j * 10 + k  * .1;
           // Add the row to the Orders table.
           tOrders.Rows.Add(newRow2);
        }
     }
  }
}

継承階層継承階層
System.Object
  System.Windows.Forms.BindingContext
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingContext メンバ
System.Windows.Forms 名前空間
BindingManagerBase
Binding クラス
BindingsCollection

BindingContext コンストラクタ

BindingContext クラスの新しいインスタンスを初期化します。

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

Dim instance As New BindingContext
public BindingContext ()
public:
BindingContext ()
public BindingContext ()
public function BindingContext ()
解説解説

同じデータ ソースに対して複数の BindingManagerBase インスタンスが必要な場合は、新しい BindingContext を作成し、それを Control から継承されるオブジェクトの BindingContext プロパティに設定します。たとえば、2 つの異なる BindingContext オブジェクトが管理する 2 つの BindingManagerBase がある場合、各 BindingManagerBase の Position プロパティを別々の値に設定できます。これにより、データ バインド コントロールの各セットに、同じデータ ソースからの異なる値が表示されます。

使用例使用例

2 つの新しい BindingContext オブジェクトを作成し、各オブジェクトを GroupBox コントロールの BindingContext プロパティに割り当てるコード例を次に示します。GroupBox1 には TextBox1 が格納され、GroupBox2 には TextBox2 が格納されます。この処理には、Control.ControlCollection クラスの AddRange メソッドが使用されます。さらに、この例では、Binding オブジェクトを 2 つの TextBox コントロールに追加し、各コントロールを同じデータ ソースおよび同じデータ メンバにバインドしています。また、GroupBox コントロールで BindingContext を使用して、異なる BindingManagerBase オブジェクトの Position プロパティを設定する 2 つのイベント ハンドラも示しています。

Private Sub BindControls()
    Dim bcG1 As New BindingContext()
    Dim bcG2 As New BindingContext()
       
    groupBox1.BindingContext = bcG1
    groupBox2.BindingContext = bcG2
       
    textBox1.DataBindings.Add("Text", ds, "Customers.CustName")
    textBox2.DataBindings.Add("Text", ds, "Customers.CustName")
End Sub    
   
Private Sub Button1_Click(sender As
 Object, e As EventArgs) Handles
 Button1.Click
    groupBox1.BindingContext(ds, "Customers").Position
 += 1
End Sub    
   
Private Sub Button2_Click(sender As
 Object, e As EventArgs) Handles
 Button2.Click
    groupBox2.BindingContext(ds, "Customers").Position
 += 1
End Sub

private void BindControls()
{
   BindingContext bcG1 = new BindingContext();
   BindingContext bcG2 = new BindingContext();

   groupBox1.BindingContext = bcG1;
   groupBox2.BindingContext = bcG2;

   textBox1.DataBindings.Add("Text", ds, "Customers.CustName");
   textBox2.DataBindings.Add("Text", ds, "Customers.CustName");
}

private void Button1_Click(object sender, EventArgs
 e)
{
   groupBox1.BindingContext[ds, "Customers"].Position += 1;         
}

private void Button2_Click(object sender, EventArgs
 e)
{
   groupBox2.BindingContext[ds, "Customers"].Position += 1;
}
void BindControls()
{
   System::Windows::Forms::BindingContext^ bcG1 = gcnew System::Windows::Forms::BindingContext;
   System::Windows::Forms::BindingContext^ bcG2 = gcnew System::Windows::Forms::BindingContext;
   groupBox1->BindingContext = bcG1;
   groupBox2->BindingContext = bcG2;
   textBox1->DataBindings->Add( "Text", ds, "Customers.CustName"
 );
   textBox2->DataBindings->Add( "Text", ds, "Customers.CustName"
 );
}

void Button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   groupBox1->BindingContext[ds, "Customers"]->Position = groupBox1->BindingContext[ds,
 "Customers"]->Position + 1;
}

void Button2_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   groupBox2->BindingContext[ds, "Customers"]->Position = groupBox2->BindingContext[ds,
 "Customers"]->Position + 1;
}

private void BindControls()
{
    BindingContext bcG1 = new BindingContext();
    BindingContext bcG2 = new BindingContext();
    groupBox1.set_BindingContext(bcG1);
    groupBox2.set_BindingContext(bcG2);
    textBox1.get_DataBindings().Add("Text", ds, "Customers.CustName");
    textBox2.get_DataBindings().Add("Text", ds, "Customers.CustName");
} //BindControls

private void button1_Click(Object sender, EventArgs
 e)
{
    groupBox1.get_BindingContext().get_Item(ds, "Customers").set_Position
        (groupBox1.get_BindingContext().get_Item(ds, "Customers").
        get_Position() + 1);
} //button1_Click

private void button2_Click(Object sender, EventArgs
 e)
{
    groupBox2.get_BindingContext().get_Item(ds, "Customers").set_Position
        (groupBox2.get_BindingContext().get_Item(ds, "Customers").
        get_Position() + 1);
} //button2_Click
private function BindControls()
{
   var bcG1 : System.Windows.Forms.BindingContext = new
 System.Windows.Forms.BindingContext;
   var bcG2 : System.Windows.Forms.BindingContext = new
 System.Windows.Forms.BindingContext;

   button1.BindingContext = bcG1;
   button2.BindingContext = bcG2;

   textBox1.DataBindings.Add(new Binding
      ("Text", ds, "customers.custName"));
   textBox2.DataBindings.Add(new Binding
      ("Text", ds, "customers.custName"));

   // Get the BindingManagerBase for the Customers table. 
   bmCustomers = this.BindingContext [ds, "Customers"];
}

private function Button1_Click(sender, e :
 EventArgs)
{
   bmCustomers.Position += 1;  
}

private function Button2_Click(sender, e :
 EventArgs)
{
   bmCustomers.Position -= 1;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingContext クラス
BindingContext メンバ
System.Windows.Forms 名前空間
BindingManagerBase

BindingContext プロパティ


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

  名前 説明
パブリック プロパティ Item オーバーロードされます。 BindingManagerBase を取得します。
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot 同期 (スレッド セーフティ) に使用するオブジェクトを取得します。
参照参照

関連項目

BindingContext クラス
System.Windows.Forms 名前空間
BindingManagerBase
Binding クラス
BindingsCollection

BindingContext メソッド


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

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo コレクションのインデックスを開始位置として、指定した配列にコレクション要素をコピーします。
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクションの列挙子を取得します。
参照参照

関連項目

BindingContext クラス
System.Windows.Forms 名前空間
BindingManagerBase
Binding クラス
BindingsCollection

BindingContext メンバ

Control クラスから継承されるすべてのオブジェクトについて、BindingManagerBase オブジェクトのコレクションを管理します。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド BindingContext BindingContext クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Item オーバーロードされます。 BindingManagerBase を取得します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント CollectionChanged 処理されると、常に NotImplementedException が発生します。
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo コレクションのインデックスを開始位置として、指定した配列にコレクション要素をコピーします。
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクションの列挙子を取得します。
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot 同期 (スレッド セーフティ) に使用するオブジェクトを取得します。
参照参照

関連項目

BindingContext クラス
System.Windows.Forms 名前空間
BindingManagerBase
Binding クラス
BindingsCollection



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「BindingContext」の関連用語

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

   

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



BindingContextのページの著作権

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

©2026 GRAS Group, Inc.RSS