CurrencyManager CurrencyManager CurrencyManager CurrencyManager Class

Definition

Manages a list of Binding objects.

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
Inheritance

Examples

The following code example binds a TextBox control to a column in a DataTable, gets the CurrencyManager for the binding, and sets its position.

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

Remarks

The CurrencyManager derives from the BindingManagerBase class. Use the BindingContext to return either a CurrencyManager or a PropertyManager. The actual object returned depends on the data source and data member passed to the Item[Object] property of the BindingContext. If the data source is an object that can return only a single property (instead of a list of objects), the type will be a PropertyManager. For example, if you specify a TextBox as the data source, a PropertyManager will be returned. If, on the other hand, the data source is an object that implements the IList, IListSource, or IBindingList interface, a CurrencyManager will be returned.

The Current property returns the current item in the underlying list. To change the current item, set the Position property to a new value. The value must be greater than 0 and must be less than the value of the Count property.

If the underlying data source implements the IBindingList interface, and the AllowNew property is set to true, you can use the AddNew method.

Fields

finalType finalType finalType finalType

Specifies the data type of the list.

listposition listposition listposition listposition

Specifies the current position of the CurrencyManager in the list.

onCurrentChangedHandler onCurrentChangedHandler onCurrentChangedHandler onCurrentChangedHandler

Specifies the event handler for the CurrentChanged event.

(Inherited from BindingManagerBase)
onPositionChangedHandler onPositionChangedHandler onPositionChangedHandler onPositionChangedHandler

Specifies the event handler for the PositionChanged event.

(Inherited from BindingManagerBase)

Properties

Bindings Bindings Bindings Bindings

Gets the collection of bindings being managed.

(Inherited from BindingManagerBase)
Count Count Count Count

Gets the number of items in the list.

Current Current Current Current

Gets the current item in the list.

IsBindingSuspended IsBindingSuspended IsBindingSuspended IsBindingSuspended

Gets a value indicating whether binding is suspended.

(Inherited from BindingManagerBase)
List List List List

Gets the list for this CurrencyManager.

Position Position Position Position

Gets or sets the position you are at within the list.

Methods

AddNew() AddNew() AddNew() AddNew()

Adds a new item to the underlying list.

CancelCurrentEdit() CancelCurrentEdit() CancelCurrentEdit() CancelCurrentEdit()

Cancels the current edit operation.

CheckEmpty() CheckEmpty() CheckEmpty() CheckEmpty()

Throws an exception if there is no list, or the list is empty.

EndCurrentEdit() EndCurrentEdit() EndCurrentEdit() EndCurrentEdit()

Ends the current edit operation.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetItemProperties() GetItemProperties() GetItemProperties() GetItemProperties()

Gets the property descriptor collection for the underlying list.

GetItemProperties(ArrayList, ArrayList) GetItemProperties(ArrayList, ArrayList) GetItemProperties(ArrayList, ArrayList) GetItemProperties(ArrayList, ArrayList)

Gets the collection of property descriptors for the binding using the specified ArrayList.

(Inherited from BindingManagerBase)
GetItemProperties(Type, Int32, ArrayList, ArrayList) GetItemProperties(Type, Int32, ArrayList, ArrayList) GetItemProperties(Type, Int32, ArrayList, ArrayList) GetItemProperties(Type, Int32, ArrayList, ArrayList)

Gets the list of properties of the items managed by this BindingManagerBase.

(Inherited from BindingManagerBase)
GetListName(ArrayList) GetListName(ArrayList) GetListName(ArrayList) GetListName(ArrayList)

Gets the name of the list supplying the data for the binding using the specified set of bound properties.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnBindingComplete(BindingCompleteEventArgs) OnBindingComplete(BindingCompleteEventArgs) OnBindingComplete(BindingCompleteEventArgs) OnBindingComplete(BindingCompleteEventArgs)

Raises the BindingComplete event.

(Inherited from BindingManagerBase)
OnCurrentChanged(EventArgs) OnCurrentChanged(EventArgs) OnCurrentChanged(EventArgs) OnCurrentChanged(EventArgs)

Raises the CurrentChanged event.

OnCurrentItemChanged(EventArgs) OnCurrentItemChanged(EventArgs) OnCurrentItemChanged(EventArgs) OnCurrentItemChanged(EventArgs)

Raises the CurrentItemChanged event.

OnDataError(Exception) OnDataError(Exception) OnDataError(Exception) OnDataError(Exception)

Raises the DataError event.

(Inherited from BindingManagerBase)
OnItemChanged(ItemChangedEventArgs) OnItemChanged(ItemChangedEventArgs) OnItemChanged(ItemChangedEventArgs) OnItemChanged(ItemChangedEventArgs)

Raises the ItemChanged event.

OnMetaDataChanged(EventArgs) OnMetaDataChanged(EventArgs) OnMetaDataChanged(EventArgs) OnMetaDataChanged(EventArgs)

Raises the MetaDataChanged event.

OnPositionChanged(EventArgs) OnPositionChanged(EventArgs) OnPositionChanged(EventArgs) OnPositionChanged(EventArgs)

Raises the PositionChanged event.

PullData() PullData() PullData() PullData()

Pulls data from the data-bound control into the data source, returning no information.

(Inherited from BindingManagerBase)
PushData() PushData() PushData() PushData()

Pushes data from the data source into the data-bound control, returning no information.

(Inherited from BindingManagerBase)
Refresh() Refresh() Refresh() Refresh()

Forces a repopulation of the data-bound list.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the item at the specified index.

ResumeBinding() ResumeBinding() ResumeBinding() ResumeBinding()

Resumes data binding.

SuspendBinding() SuspendBinding() SuspendBinding() SuspendBinding()

Suspends data binding to prevents changes from updating the bound data source.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
UpdateIsBinding() UpdateIsBinding() UpdateIsBinding() UpdateIsBinding()

Updates the status of the binding.

Events

BindingComplete BindingComplete BindingComplete BindingComplete

Occurs at the completion of a data-binding operation.

(Inherited from BindingManagerBase)
CurrentChanged CurrentChanged CurrentChanged CurrentChanged

Occurs when the currently bound item changes.

(Inherited from BindingManagerBase)
CurrentItemChanged CurrentItemChanged CurrentItemChanged CurrentItemChanged

Occurs when the state of the currently bound item changes.

(Inherited from BindingManagerBase)
DataError DataError DataError DataError

Occurs when an Exception is silently handled by the BindingManagerBase.

(Inherited from BindingManagerBase)
ItemChanged ItemChanged ItemChanged ItemChanged

Occurs when the current item has been altered.

ListChanged ListChanged ListChanged ListChanged

Occurs when the list changes or an item in the list changes.

MetaDataChanged MetaDataChanged MetaDataChanged MetaDataChanged

Occurs when the metadata of the List has changed.

PositionChanged PositionChanged PositionChanged PositionChanged

Occurs after the value of the Position property has changed.

(Inherited from BindingManagerBase)

Applies to

See Also