Redigeeri

Jagamisviis:


BindingContext.Contains Method

Definition

Gets a value indicating whether the BindingContext contains the specified BindingManagerBase.

Overloads

Contains(Object)

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

Contains(Object, String)

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

Contains(Object)

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

public:
 bool Contains(System::Object ^ dataSource);
public bool Contains (object dataSource);
member this.Contains : obj -> bool
Public Function Contains (dataSource As Object) As Boolean

Parameters

dataSource
Object

An Object that represents the data source.

Returns

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

Examples

The following code example uses the Contains method to determine whether a BindingManagerBase exists for each control on a form. The example passes each DataTable in a DataSet to the method.

private:
   void TryContains( DataSet^ myDataSet )
   {
      // Test each DataTable in a DataSet to see if it is bound to a BindingManagerBase.
      for each ( DataTable^ thisTable in myDataSet->Tables )
      {
         Console::WriteLine( "{0}: {1}", thisTable->TableName, this->BindingContext->Contains( thisTable ) );
      }
   }
private void TryContains(DataSet myDataSet){
    // Test each DataTable in a DataSet to see if it is bound to a BindingManagerBase.
    foreach(DataTable thisTable in myDataSet.Tables){
       Console.WriteLine(thisTable.TableName + ": " + this.BindingContext.Contains(thisTable));
    }
 }
Private Sub TryContains(myDataSet As DataSet)
   Dim thisTable As DataTable
   ' Test each DataTable in a DataSet to see if it is bound to a BindingManagerBase.
   For Each thisTable In myDataSet.Tables
      Console.WriteLine(thisTable.TableName & ": " & Me.BindingContext.Contains(thisTable))
   Next
End Sub

Remarks

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

See the Item[] property for information about returning a BindingManagerBase using only a data source.

See also

Applies to

Contains(Object, String)

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

public:
 bool Contains(System::Object ^ dataSource, System::String ^ dataMember);
public bool Contains (object dataSource, string dataMember);
public bool Contains (object dataSource, string? dataMember);
member this.Contains : obj * string -> bool
Public Function Contains (dataSource As Object, dataMember As String) As Boolean

Parameters

dataSource
Object

An Object that represents the data source.

dataMember
String

The information needed to resolve to a specific BindingManagerBase.

Returns

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

Examples

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" );
      Console::WriteLine( trueorfalse );
   }
private void TryContainsDataMember(DataSet myDataSet){
    bool trueorfalse;
    trueorfalse = this.BindingContext.Contains(myDataSet,"Suppliers");
    Console.WriteLine(trueorfalse.ToString());
 }
Private Sub TryContainsDataMember(myDataSet As DataSet)
   Dim trueorfalse As Boolean
   trueorfalse = Me.BindingContext.Contains(myDataSet, "Suppliers")
   Console.WriteLine(trueorfalse.ToString())
End Sub

Remarks

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.

See also

Applies to