Прочетете на английски Редактиране

Споделяне чрез


CurrencyManager.Current Property

Definition

Gets the current item in the list.

C#
public override object Current { get; }
C#
public override object? Current { get; }

Property Value

A list item of type Object.

Examples

The following code example uses the Current property to print the ContactName field for the current item in the list.

C#
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"]);
}

Remarks

In order to get the current item, you must know its data type in order to cast it correctly. For example, if the data source is a DataView or DataTable, you must cast the current item as a DataRowView object.

Applies to

Продукт Версии
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also