Freigeben über


CurrencyManager.Current Eigenschaft

Definition

Ruft das aktuelle Element in der Liste ab.

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

Eigenschaftswert

Ein Listenelement vom Typ Object.

Beispiele

Im folgenden Codebeispiel wird die Current -Eigenschaft verwendet, um das ContactName Feld für das aktuelle Element in der Liste zu drucken.

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

Hinweise

Um das aktuelle Element abzurufen, müssen Sie dessen Datentyp kennen, um es ordnungsgemäß zu umwandeln. Wenn die Datenquelle beispielsweise ein DataView oder DataTableist, müssen Sie das aktuelle Element als DataRowView Objekt umwandeln.

Gilt für:

Weitere Informationen