This documentation is archived and is not being maintained.

BindingContext.Contains Method (Object, String)

Gets a value indicating whether the BindingContext contains the BindingManagerBase associated with the specified data source and data member.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public bool Contains (
	Object dataSource,
	string dataMember
public boolean Contains (
	Object dataSource, 
	String dataMember
public function Contains (
	dataSource : Object, 
	dataMember : String
) : boolean
Not applicable.



An Object that represents the data source.


The information needed to resolve to a specific BindingManagerBase.

Return Value

true if the BindingContext contains the specified BindingManagerBase; otherwise, false.

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

See the Item property for information about returning a BindingManagerBase using a data source and data member.

The following code example uses the Contains method to test whether a specific BindingManagerBase exists before attempting to get it through the Item property.

private void TryContainsDataMember(DataSet myDataSet){
    bool trueorfalse;
    trueorfalse = this.BindingContext.Contains(myDataSet,"Suppliers");

private void TryContainsDataMember(DataSet myDataSet)
    boolean trueOrFalse;
    trueOrFalse = this.get_BindingContext().Contains(myDataSet,"Suppliers");
} //TryContainsDataMember

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0