Freigeben über


CurrencyManager.Current-Eigenschaft

Ruft das aktuelle Element in der Liste ab.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Overrides ReadOnly Property Current As Object
'Usage
Dim instance As CurrencyManager
Dim value As Object

value = instance.Current
public override Object Current { get; }
public:
virtual property Object^ Current {
    Object^ get () override;
}
/** @property */
public Object get_Current ()
public override function get Current () : Object

Eigenschaftenwert

Ein Listenelement vom Typ Object.

Hinweise

Zum Abrufen des aktuellen Elements muss dessen Datentyp bekannt sein, um es richtig umzuwandeln. Wenn eine Datenquelle beispielsweise DataView oder DataTable darstellt, muss das aktuelle Element als DataRowView-Objekt umgewandelt werden.

Beispiel

Im folgenden Codebeispiel wird mithilfe der Current-Eigenschaft das ContactName-Feld für das aktuelle Elemente in der Liste gedruckt.

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 'GetCurrentItem
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"]);
}
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.
        get_BindingContext().get_Item((Int32)0));
    // Get the current item cast as a DataRowView.
    DataRowView myDataRowView;
    myDataRowView = (DataRowView)(myCurrencyManager.get_Current());
    // Print the column named ContactName.
    Console.WriteLine(myDataRowView.get_Item("ContactName"));
} //GetCurrentItem
private function GetCurrentItem() {
    var myCurrencyManager : CurrencyManager;
    // Get the CurrencyManager of a TextBox control.
    myCurrencyManager = CurrencyManager(textBox1.BindingContext[0]);
    // Get the current item cast as a DataRowView.
    var myDataRowView : DataRowView;
    myDataRowView = DataRowView(myCurrencyManager.Current);
    // Print the column named ContactName.
    Console.WriteLine(myDataRowView["ContactName"]);
}

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

CurrencyManager-Klasse
CurrencyManager-Member
System.Windows.Forms-Namespace
DataRowView
List
Position
CurrencyManager.Count-Eigenschaft