共用方式為


CurrencyManager.Current 屬性

定義

取得清單中的目前項目。

public:
 virtual property System::Object ^ Current { System::Object ^ get(); };
public override object Current { get; }
member this.Current : obj
Public Overrides ReadOnly Property Current As Object

屬性值

Object

Object 型別的清單項目。

範例

下列程式碼範例會 Current 使用 屬性來列印 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.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

備註

若要取得目前的專案,您必須知道其資料類型,才能正確轉換。 例如,如果資料來源是 DataViewDataTable ,您必須將目前的專案轉換成 DataRowView 物件。

適用於

另請參閱