CurrencyManager.Current Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u het huidige item in de lijst op.
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
Waarde van eigenschap
Een lijstitem van het type Object.
Voorbeelden
In het volgende codevoorbeeld wordt de Current eigenschap gebruikt om het ContactName veld voor het huidige item in de lijst af te drukken.
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
Opmerkingen
Als u het huidige item wilt ophalen, moet u het gegevenstype weten om het correct te kunnen casten. Als de gegevensbron bijvoorbeeld een DataView of DataTableis, moet u het huidige item casten als een DataRowView object.