CurrencyManager 類別

定義

管理 Binding 物件的清單。

public ref class CurrencyManager : System::Windows::Forms::BindingManagerBase
public class CurrencyManager : System.Windows.Forms.BindingManagerBase
type CurrencyManager = class
    inherit BindingManagerBase
Public Class CurrencyManager
Inherits BindingManagerBase
繼承
CurrencyManager

範例

下列程式碼範例會將 TextBox 控制項系結至 中的資料 DataTable 行,取得 CurrencyManager 系結的 ,並設定其位置。

CurrencyManager^ myCurrencyManager;
void BindControl( DataTable^ myTable )
{
   
   // Bind a TextBox control to a DataTable column in a DataSet.
   textBox1->DataBindings->Add( "Text", myTable, "CompanyName" );
   
   // Specify the CurrencyManager for the DataTable.
   this->myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]);
   
   // Set the initial Position of the control.
   this->myCurrencyManager->Position = 0;
}

void MoveNext( CurrencyManager^ myCurrencyManager )
{
   if ( myCurrencyManager->Position == myCurrencyManager->Count - 1 )
   {
      MessageBox::Show( "You're at end of the records" );
   }
   else
   {
      myCurrencyManager->Position += 1;
   }
}

void MoveFirst( CurrencyManager^ myCurrencyManager )
{
   myCurrencyManager->Position = 0;
}

void MovePrevious( CurrencyManager^ myCurrencyManager )
{
   if ( myCurrencyManager->Position == 0 )
   {
      MessageBox::Show( "You're at the beginning of the records." );
   }
   else
   {
      myCurrencyManager->Position -= 1;
   }
}

void MoveLast( CurrencyManager^ myCurrencyManager )
{
   myCurrencyManager->Position = myCurrencyManager->Count - 1;
}
private CurrencyManager myCurrencyManager;
 
 private void BindControl(DataTable myTable){
    // Bind a TextBox control to a DataTable column in a DataSet.
    textBox1.DataBindings.Add("Text", myTable, "CompanyName");
    // Specify the CurrencyManager for the DataTable.
    myCurrencyManager = (CurrencyManager)this.BindingContext[myTable];
    // Set the initial Position of the control.
    myCurrencyManager.Position = 0;
 }
 
 private void MoveNext(CurrencyManager myCurrencyManager){
    if (myCurrencyManager.Position == myCurrencyManager.Count - 1){
       MessageBox.Show("You're at end of the records");
    }
    else{
      myCurrencyManager.Position += 1;
    }
 }
 
 private void MoveFirst(CurrencyManager myCurrencyManager){
    myCurrencyManager.Position = 0;
 }
 
 private void MovePrevious(CurrencyManager myCurrencyManager ){
    if(myCurrencyManager.Position == 0) {
       MessageBox.Show("You're at the beginning of the records.");
    }   
    else{
       myCurrencyManager.Position -= 1;
    }
 }
 
 private void MoveLast(CurrencyManager myCurrencyManager){
    myCurrencyManager.Position = myCurrencyManager.Count - 1;
 }
' Place the next line into the Declarations section of the form.
 Private myCurrencyManager As CurrencyManager
 
 Private Sub BindControl(myTable As DataTable)
    ' Bind a TextBox control to a DataTable column in a DataSet.
    TextBox1.DataBindings.Add("Text", myTable, "CompanyName")
    ' Specify the CurrencyManager for the DataTable.
    myCurrencyManager = CType(me.BindingContext(myTable), CurrencyManager)
    ' Set the initial Position of the control.
    myCurrencyManager.Position = 0
 End Sub
 
 Private Sub MoveNext(myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Position = myCurrencyManager.Count - 1 Then 
       MessageBox.Show("You're at end of the records")
    Else
       myCurrencyManager.Position += 1
    End If
 End Sub
 
 Private Sub MoveFirst(myCurrencyManager As CurrencyManager)
    myCurrencyManager.Position = 0
 End Sub
 
 Private Sub MovePrevious(myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Position = 0 Then
       MessageBox.Show("You're at the beginning of the records.")
    Else
       myCurrencyManager.Position -= 1
    End if
 End Sub
 
 Private Sub MoveLast(myCurrencyManager As CurrencyManager)
    myCurrencyManager.Position = myCurrencyManager.Count - 1
 End Sub

備註

CurrencyManager衍生自 BindingManagerBase 類別。 BindingContext使用 傳回 CurrencyManagerPropertyManager 。 傳回的實際物件取決於傳遞給 Item[] 之 屬性的 BindingContext 資料來源和資料成員。 如果資料來源是只能傳回單一屬性的物件 (,而不是) 的物件清單,則類型會是 PropertyManager 。 例如,如果您將 指定 TextBox 為數據源, PropertyManager 則會傳回 。 另一方面,如果資料來源是實 IList 作 、 IListSourceIBindingList 介面的物件, CurrencyManager 則會傳回 。

屬性會 Current 傳回基礎清單中的目前專案。 若要變更目前的專案,請將 Position 屬性設定為新的值。 值必須大於 0,而且必須小於 屬性的值 Count

如果基礎資料來源實作 IBindingList 介面,且 AllowNew 屬性設定為 true ,您可以使用 AddNew 方法。

欄位

finalType

指定清單的資料類型。

listposition

指定清單中 CurrencyManager 的目前位置。

onCurrentChangedHandler

指定 CurrentChanged 事件的事件處理常式。

(繼承來源 BindingManagerBase)
onPositionChangedHandler

指定 PositionChanged 事件的事件處理常式。

(繼承來源 BindingManagerBase)

屬性

Bindings

取得受管理的繫結集合。

(繼承來源 BindingManagerBase)
Count

取得清單中的項目數。

Current

取得清單中的目前項目。

IsBindingSuspended

取得值,指出繫結作業是否已暫止。

(繼承來源 BindingManagerBase)
List

取得這個 CurrencyManager 的清單。

Position

取得或設定您位於清單中的位置。

方法

AddNew()

將新的項目加入基礎清單中。

CancelCurrentEdit()

取消目前的編輯作業。

CheckEmpty()

如果沒有任何清單,或者清單是空白的,便擲回例外狀況。

EndCurrentEdit()

結束目前的編輯作業。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetItemProperties()

取得基礎清單的屬性描述項集合。

GetItemProperties(ArrayList, ArrayList)

使用指定的 ArrayList,取得繫結的屬性描述項集合。

(繼承來源 BindingManagerBase)
GetItemProperties(Type, Int32, ArrayList, ArrayList)

取得由這個 BindingManagerBase 所管理項目的屬性清單。

(繼承來源 BindingManagerBase)
GetListName(ArrayList)

使用指定的繫結屬性集,取得提供繫結資料的清單名稱。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnBindingComplete(BindingCompleteEventArgs)

引發 BindingComplete 事件。

(繼承來源 BindingManagerBase)
OnCurrentChanged(EventArgs)

引發 CurrentChanged 事件。

OnCurrentItemChanged(EventArgs)

引發 CurrentItemChanged 事件。

OnCurrentItemChanged(EventArgs)

引發 CurrentItemChanged 事件。

(繼承來源 BindingManagerBase)
OnDataError(Exception)

引發 DataError 事件。

(繼承來源 BindingManagerBase)
OnItemChanged(ItemChangedEventArgs)

引發 ItemChanged 事件。

OnMetaDataChanged(EventArgs)

引發 MetaDataChanged 事件。

OnPositionChanged(EventArgs)

引發 PositionChanged 事件。

PullData()

從資料繫結的控制項取出資料送入資料來源,而不需傳回任何資訊。

(繼承來源 BindingManagerBase)
PushData()

將資料來源中的資料送入資料繫結的控制項,而不需傳回任何資訊。

(繼承來源 BindingManagerBase)
Refresh()

強制重新填入資料繫結清單。

RemoveAt(Int32)

移除指定之索引處的項目。

ResumeBinding()

繼續資料繫結。

SuspendBinding()

暫止資料繫結以防止變更更新繫結的資料來源。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
UpdateIsBinding()

更新繫結的狀態。

事件

BindingComplete

發生於資料繫結作業完成時。

(繼承來源 BindingManagerBase)
CurrentChanged

發生於目前繫結的項目變更時。

(繼承來源 BindingManagerBase)
CurrentItemChanged

發生於目前繫結的項目之狀態變更時。

(繼承來源 BindingManagerBase)
DataError

Exception 以無訊息模式處理 BindingManagerBase 時發生。

(繼承來源 BindingManagerBase)
ItemChanged

發生於目前項目變更時。

ListChanged

發生於清單變更或清單項目變更時。

MetaDataChanged

發生於 List 的中繼資料 (Metadata) 變更時。

PositionChanged

發生於 Position 屬性的值已變更後。

(繼承來源 BindingManagerBase)

適用於

另請參閱