次の方法で共有


BindingContext.Item プロパティ (Object)

指定したデータ ソースに関連付けられた BindingManagerBase を取得します。

[C#] C# では、このプロパティは BindingContext クラスのインデクサになります。

Overloads Public Default ReadOnly Property Item( _
   ByVal dataSource As Object _) As BindingManagerBase
[C#]
public BindingManagerBase this[objectdataSource] {get;}
[C++]
public: __property BindingManagerBase* get_Item(Object* dataSource);
[JScript]
returnValue = BindingContextObject.Item(dataSource);またはreturnValue = BindingContextObject(dataSource);

[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。

引数 [JScript]

パラメータ [Visual Basic, C#, C++]

プロパティ値

指定したデータ ソースの BindingManagerBase

解説

目的の BindingManagerBase でナビゲーション パスが必要ない場合は、このオーバーロードを使用します。たとえば BindingManagerBase によって、 DataSource として ArrayList または DataTable を使用する Binding オブジェクトのセットを管理する場合、ナビゲーション パスは不要です。

メモ    Item プロパティは、常に BindingManagerBase を返し、 null 参照 (Visual Basic では Nothing) を返すことはありません。

使用できるデータ ソースの一覧と、コントロールとデータ ソースの間のバインディング作成の詳細については、 Binding クラスのトピックを参照してください。

使用例

3 つの BindingManagerBase オブジェクトを返す例を次に示します。3 つのオブジェクトとは、 DataViewArrayList 、および TextBox コントロールに属する Binding オブジェクトの DataSource です。

 
Private Sub ReturnBindingManagerBase()
   ' Get the BindingManagerBase for a DataView. 
   Dim bmCustomers As BindingManagerBase = _
      Me.BindingContext(myDataView)

   ' Get the BindingManagerBase for an ArrayList.
   Dim bmOrders As BindingManagerBase = _
      Me.BindingContext(myArrayList)

   ' Get the BindingManagerBase for a TextBox control.
   Dim baseArray As BindingManagerBase = _
      Me.BindingContext(Text1.DataBindings(0).DataSource)
End Sub


[C#] 
private void ReturnBindingManagerBase()
{
   // Get the BindingManagerBase for a DataView. 
   BindingManagerBase bmCustomers = 
   this.BindingContext [myDataView];

   /* Get the BindingManagerBase for an ArrayList. */ 
   BindingManagerBase bmOrders = 
   this.BindingContext[myArrayList];

   // Get the BindingManagerBase for a TextBox control.
   BindingManagerBase baseArray = 
   this.BindingContext[textBox1.DataBindings[0].DataSource];
}


[C++] 
private:
void ReturnBindingManagerBase()
{
   // Get the BindingManagerBase for a DataView. 
   BindingManagerBase* bmCustomers = 
   this->BindingContext->Item[myDataView];

   /* Get the BindingManagerBase for an ArrayList. */ 
   BindingManagerBase* bmOrders = 
   this->BindingContext->Item[myArrayList];

   // Get the BindingManagerBase for a TextBox control.
   BindingManagerBase* baseArray = 
   this->BindingContext->Item[textBox1->DataBindings->Item[0]->DataSource];
}


[JScript] 
private function ReturnBindingManagerBase()
{
   // Get the BindingManagerBase for a DataView. 
   var bmCustomers : BindingManagerBase = 
   this.BindingContext [myDataView];

   /* Get the BindingManagerBase for an ArrayList. */ 
   var bmOrders : BindingManagerBase = 
   this.BindingContext[myArrayList];

   // Get the BindingManagerBase for a TextBox control.
   var baseArray : BindingManagerBase = 
   this.BindingContext[textBox1.DataBindings[0].DataSource];
}

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

BindingContext クラス | BindingContext メンバ | System.Windows.Forms 名前空間 | BindingContext.Item オーバーロードの一覧 | BindingsCollection | Binding