Compartir a través de


CurrencyManager.Current Propiedad

Definición

Obtiene el elemento actual de la lista.

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

Valor de propiedad

Un elemento de lista de tipo Object.

Ejemplos

En el ejemplo de código siguiente se usa la Current propiedad para imprimir el ContactName campo del elemento actual de la lista.

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

Comentarios

Para obtener el elemento actual, debe conocer su tipo de datos para convertirlo correctamente. Por ejemplo, si el origen de datos es o DataViewDataTable, debe convertir el elemento actual como un DataRowView objeto .

Se aplica a

Consulte también