ControlBindingsCollection.Item[String] Propriété

Définition

Obtient le Binding spécifié par le nom de la propriété du contrôle.

public:
 property System::Windows::Forms::Binding ^ default[System::String ^] { System::Windows::Forms::Binding ^ get(System::String ^ propertyName); };
public System.Windows.Forms.Binding this[string propertyName] { get; }
member this.Item(string) : System.Windows.Forms.Binding
Default Public ReadOnly Property Item(propertyName As String) As Binding

Paramètres

propertyName
String

Nom de la propriété dans le contrôle lié aux données.

Valeur de propriété

Binding

Binding qui lie la propriété du contrôle spécifiée à une source de données.

Exemples

L’exemple de code suivant retourne un seul Binding à partir d’un ControlBindingsCollection.

void PrintValue()
{
   ControlBindingsCollection^ myControlBindings;
   myControlBindings = textBox1->DataBindings;
   
   // Get the Binding for the Text property.
   Binding^ myBinding = myControlBindings[ "Text" ];
   
   // Assuming the data source is a DataTable.
   DataRowView^ drv;
   drv = dynamic_cast<DataRowView^>(myBinding->BindingManagerBase->Current);
   
   // Assuming a column named S"custName" exists, print the value.
   Console::WriteLine( drv[ "custName" ] );
}
private void PrintValue()
{
   ControlBindingsCollection myControlBindings;
   myControlBindings = textBox1.DataBindings;

   // Get the Binding for the Text property.
   Binding myBinding = myControlBindings["Text"];

   // Assuming the data source is a DataTable.
   DataRowView drv;
   drv = (DataRowView) myBinding.BindingManagerBase.Current;

   // Assuming a column named "custName" exists, print the value.
   Console.WriteLine(drv["custName"]);
}
Private Sub PrintValue()

   Dim myControlBindings As ControlBindingsCollection = _
   textBox1.DataBindings

   ' Get the Binding for the Text property.
   Dim myBinding As Binding = myControlBindings("Text")

   ' Assuming the data source is a DataTable.
   Dim drv As DataRowView = _
   CType( myBinding.BindingManagerBase.Current, DataRowView)

   ' Assuming a column named "custName" exists, print the value.
   Console.WriteLine(drv("custName"))
End Sub

Remarques

Si la propriété spécifiée ne correspond pas à une liaison dans la collection, Item[] retourne null.

S’applique à