Export (0) Print
Expand All

BindingContext.Item Property (Object, String)

Gets a BindingManagerBase that is associated with the specified data source and data member.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public BindingManagerBase this [
	Object dataSource,
	string dataMember
] { get; }
/** @property */
public BindingManagerBase get_Item (Object dataSource, String dataMember)

JScript supports the use of indexed properties, but not the declaration of new ones.



The data source associated with a particular BindingManagerBase.


A navigation path containing the information that resolves to a specific BindingManagerBase.

Property Value

The BindingManagerBase for the specified data source and data member.

Exception typeCondition


The specified dataMember does not exist within the data source.

Use this overload when the BindingManagerBase manages a set of Binding objects for which the data source contains multiple objects. For example, a DataSet can contain several DataTable objects linked by DataRelation objects. In such a case, the navigation path is required to enable the BindingContext to return the correct BindingManagerBase.


The Item property will always return a BindingManagerBase, when the dataMember parameter is valid. It will never return a null reference (Nothing in Visual Basic).

See the Binding class for a list of possible data sources and for information about creating bindings between controls and data sources.

If the desired BindingManagerBase manages a list, the navigation path must also end with a list. For example, the following C# code binds a TextBox control to the order date in a table of orders. The navigation path includes the TableName, the RelationName, and the ColumnName. However, the BindingManagerBase must be retrieved using only the TableName and RelationName (which resolves to a list).

// The navigation path for a Binding ends with a property.
("Text", dataSet1, "Customers.custToOrders.OrderDate");
// The navigation path for the BindingManagerBase ends with a list.
BindingManagerBase bmOrders = this.BindingContext
[dataSet1, "Customers.custToOrders"];

When returning a BindingManagerBase, you should use the same data source as the Binding and modify only the navigation path.

Use the Contains method to determine if the desired BindingManagerBase already exists.

The following code example uses the BindingContext to return BindingManagerBase objects that manage Binding objects. The Binding objects are bound to a data source that contains multiple objects. In each case, the specified data member is used to resolve to the correct object.

//The following lines go into the Declarations section of the form.
private var cmOrders : BindingManagerBase;
private var cmProducts : BindingManagerBase;
private var dsOrders : DataSet;
private var dsProducts : DataSet;
private var Combo1 : ComboBox;
private var Combo2 : ComboBox;
private var DataGrid1 : DataGrid;
private var DataGrid2 : DataGrid;
private var myBindingManagerBase : BindingManagerBase;

static function Main()

// Not shown: code to create and populate DataSets with tables.
// The code assumes the dsOrders has two tables, Orders and OrderDetails,
// and dsProducts has two tables, Suppliers and Products.

private function BindControls()
   // Bind four controls to two data sources: 
   // two DataGrid controls and two ComboBoxes.

   Combo1.DataBindings.Add("Text", dsProducts.Tables("Suppliers"), "CompanyName");
   DataGrid1.DataSource = dsProducts;
   DataGrid1.DataMember = "Products";

   Combo2.DataBindings.Add("Text", dsOrders.Tables("Orders"), "Customer");
   DataGrid2.SetDataBinding(dsOrders, "OrderDetails");

private function GetBindingManagerBases()
   // Get the BindingManagerBase objects for each data source.
   cmOrders = BindingContext(dsOrders, "Orders");
   cmProducts = BindingContext(dsProducts, "Products");

private function GetBindingManagerBase()
   // Set the BindingManagerBase for the bound control using the BindingContext
   // of the Win Form. Pass the same table to the BindingContext as the bound control.
   myBindingManagerBase = BindingContext(dsProducts.Tables("Suppliers"));

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

© 2014 Microsoft