Partager via


CurrencyManager.Current Propriété

Définition

Obtient l'élément en cours dans la liste.

public:
 virtual property System::Object ^ Current { System::Object ^ get(); };
public override object Current { get; }
public override object? Current { get; }
member this.Current : obj
Public Overrides ReadOnly Property Current As Object

Valeur de propriété

Élément de liste de type Object.

Exemples

L’exemple de code suivant utilise la Current propriété pour imprimer le ContactName champ de l’élément actif dans la liste.

void GetCurrentItem()
{
   CurrencyManager^ myCurrencyManager;
   
   // Get the CurrencyManager of a TextBox control.
   myCurrencyManager = dynamic_cast<CurrencyManager^>(textBox1->BindingContext[nullptr]);
   
   // Get the current item cast as a DataRowView.
   DataRowView^ myDataRowView;
   myDataRowView = dynamic_cast<DataRowView^>(myCurrencyManager->Current);
   
   // Print the column named ContactName.
   Console::WriteLine( myDataRowView[ "ContactName" ] );
}
private void GetCurrentItem() {
    CurrencyManager myCurrencyManager;
    // Get the CurrencyManager of a TextBox control.
    myCurrencyManager = (CurrencyManager)textBox1.BindingContext[0];
    // Get the current item cast as a DataRowView.
    DataRowView myDataRowView;
    myDataRowView = (DataRowView) myCurrencyManager.Current;
    // Print the column named ContactName.
    Console.WriteLine(myDataRowView["ContactName"]);
}
Private Sub GetCurrentItem()
    Dim myCurrencyManager As CurrencyManager
    ' Get the CurrencyManager of a TextBox control.
    myCurrencyManager = CType(textBox1.BindingContext(0), CurrencyManager)
    ' Get the current item cast as a DataRowView.
    Dim myDataRowView As DataRowView
    myDataRowView = CType(myCurrencyManager.Current, DataRowView)
    ' Print the column named ContactName.
    Console.WriteLine(myDataRowView("ContactName"))
End Sub

Remarques

Pour obtenir l’élément actif, vous devez connaître son type de données afin de le caster correctement. Par exemple, si la source de données est un DataView ou DataTable, vous devez caster l’élément actif en tant qu’objet DataRowView .

S’applique à

Voir aussi