共用方式為


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 回傳 a CurrencyManager 或 a PropertyManager。 實際回傳的物件取決於傳入Item[]BindingContext屬性的資料來源與資料成員。 若資料來源為只能回傳單一屬性(而非物件清單)的物件,則該型別將為 PropertyManager。 例如,如果你指定 a TextBox 作為資料來源,就會回傳 a PropertyManager 。 反之,若資料來源是實 IList作 、 IListSourceIBindingList 介面的物件,則會回傳 a CurrencyManager

該屬性會 Current 回傳底層清單中目前的項目。 要更改目前項目,請將屬性設定 Position 為新的值。 價值必須大於0,且必須低於該 Count 房產的價值。

如果底層資料來源實作了該 IBindingList 介面,且 AllowNew 屬性設定為 true,你就可以使用該 AddNew 方法。

欄位

名稱 Description
finalType

指定清單的資料類型。

listposition

指定 在 CurrencyManager 列表中的當前位置。

onCurrentChangedHandler

指定該事件的事件處理程序 CurrentChanged

(繼承來源 BindingManagerBase)
onPositionChangedHandler

指定該事件的事件處理程序 PositionChanged

(繼承來源 BindingManagerBase)

屬性

名稱 Description
Bindings

負責管理綁定的集合。

(繼承來源 BindingManagerBase)
Count

會取得清單中的項目數量。

Current

取得清單中目前的項目。

IsBindingSuspended

會得到一個值,表示綁定是否被暫停。

(繼承來源 BindingManagerBase)
List

拿到這個 CurrencyManager清單。

Position

取得或設定你在名單中的位置。

方法

名稱 Description
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 事件。

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()

更新綁定狀態。

事件

名稱 Description
BindingComplete

發生在資料綁定操作完成時。

(繼承來源 BindingManagerBase)
CurrentChanged

當目前綁定的物品改變時會發生。

(繼承來源 BindingManagerBase)
CurrentItemChanged

當當前綁定項目的狀態改變時,會發生這種情況。

(繼承來源 BindingManagerBase)
DataError

當 a Exception 被 靜默處理 BindingManagerBase時會發生。

(繼承來源 BindingManagerBase)
ItemChanged

當當前物品被更改時會發生。

ListChanged

當清單變更或清單中的項目改變時,會發生這種情況。

MetaDataChanged

當 的 List 元資料改變時會發生。

PositionChanged

發生在房產價值 Position 變動之後。

(繼承來源 BindingManagerBase)

適用於

另請參閱