CurrencyManager.Current Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene l'elemento corrente nell'elenco.
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
Valore della proprietà
Elemento di elenco di tipo Object.
Esempio
Nell'esempio di codice seguente viene utilizzata la Current proprietà per stampare il ContactName campo per l'elemento corrente nell'elenco.
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
Commenti
Per ottenere l'elemento corrente, è necessario conoscerne il tipo di dati per eseguirne correttamente il cast. Ad esempio, se l'origine dati è un DataView oggetto o DataTable, è necessario eseguire il cast dell'elemento corrente come DataRowView oggetto .