CurrencyManager.Current 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得清單中的目前項目。
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 型別的清單項目。
範例
下列程式碼範例會 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
備註
若要取得目前的專案,您必須知道其資料類型,才能正確轉換。 例如,如果資料來源是 DataView 或 DataTable ,您必須將目前的專案轉換成 DataRowView 物件。