Binding 개체의 목록을 관리합니다.
네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

CurrencyManager는 BindingManagerBase 클래스에서 파생됩니다. CurrencyManager 또는 PropertyManager를 반환하려면BindingContext를 사용합니다. 실제로 반환되는 개체는 BindingContext의 Item 속성에 전달되는 데이터 소스 및 데이터 멤버에 따라 다릅니다. 데이터 소스가 개체 목록이 아니라 하나의 속성만 반환할 수 있는 개체이면 형식은 PropertyManager입니다. 예를 들어 TextBox를 데이터 소스로 지정하면 PropertyManager가 반환됩니다. 반면에 데이터 소스가 IList, IListSource 또는 IBindingList 인터페이스를 구현하는 개체이면CurrencyManager가 반환됩니다.
Current 속성은 기본 목록에서 현재 항목을 반환합니다. 현재 항목을 변경하려면 Position 속성을 새 값으로 설정해야 합니다. 값은 0보다 크고Count 속성 값보다 작아야 합니다.
내부 데이터 소스가 IBindingList 인터페이스를 구현하고 AllowNew 속성이 true로 설정되어 있으면, AddNew 메서드를 사용할 수 있습니다.

다음 코드 예제에서는 TextBox 컨트롤을 DataTable에 있는 열에 바인딩하고, 이 바인딩에 대한 CurrencyManager를 가져오고, 해당 위치를 설정합니다.
C#
|
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; } |