CurrencyManager Class

Manages a list of Binding objects.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ref class CurrencyManager : public BindingManagerBase

The CurrencyManager type exposes the following members.

  NameDescription
Public propertyBindingsGets the collection of bindings being managed. (Inherited from BindingManagerBase.)
Public propertyCountGets the number of items in the list. (Overrides BindingManagerBase::Count.)
Public propertyCurrentGets the current item in the list. (Overrides BindingManagerBase::Current.)
Public propertyIsBindingSuspendedGets a value indicating whether binding is suspended. (Inherited from BindingManagerBase.)
Public propertyListGets the list for this CurrencyManager.
Public propertyPositionGets or sets the position you are at within the list. (Overrides BindingManagerBase::Position.)
Top

  NameDescription
Public methodAddNewAdds a new item to the underlying list. (Overrides BindingManagerBase::AddNew().)
Public methodCancelCurrentEditCancels the current edit operation. (Overrides BindingManagerBase::CancelCurrentEdit().)
Protected methodCheckEmptyInfrastructure. Throws an exception if there is no list, or the list is empty.
Public methodEndCurrentEditEnds the current edit operation. (Overrides BindingManagerBase::EndCurrentEdit().)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetItemProperties()Gets the property descriptor collection for the underlying list. (Overrides BindingManagerBase::GetItemProperties().)
Protected methodGetItemProperties(ArrayList, ArrayList)Gets the collection of property descriptors for the binding using the specified ArrayList. (Inherited from BindingManagerBase.)
Protected methodGetItemProperties(Type, Int32, ArrayList, ArrayList)Gets the list of properties of the items managed by this BindingManagerBase. (Inherited from BindingManagerBase.)
Protected methodGetListNameGets the name of the list supplying the data for the binding using the specified set of bound properties. (Overrides BindingManagerBase::GetListName(ArrayList).)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnBindingCompleteRaises the BindingComplete event. (Inherited from BindingManagerBase.)
Protected methodOnCurrentChangedRaises the CurrentChanged event. (Overrides BindingManagerBase::OnCurrentChanged(EventArgs).)
Protected methodOnCurrentItemChangedRaises the CurrentItemChanged event. (Overrides BindingManagerBase::OnCurrentItemChanged(EventArgs).)
Protected methodOnDataErrorRaises the DataError event. (Inherited from BindingManagerBase.)
Protected methodOnItemChangedRaises the ItemChanged event.
Protected methodOnMetaDataChangedRaises the MetaDataChanged event.
Protected methodOnPositionChangedRaises the PositionChanged event.
Protected methodPullDataPulls data from the data-bound control into the data source, returning no information. (Inherited from BindingManagerBase.)
Protected methodPushDataPushes data from the data source into the data-bound control, returning no information. (Inherited from BindingManagerBase.)
Public methodRefreshForces a repopulation of the data-bound list.
Public methodRemoveAtRemoves the item at the specified index. (Overrides BindingManagerBase::RemoveAt(Int32).)
Public methodResumeBindingResumes data binding. (Overrides BindingManagerBase::ResumeBinding().)
Public methodSuspendBindingSuspends data binding to prevents changes from updating the bound data source. (Overrides BindingManagerBase::SuspendBinding().)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodUpdateIsBindingInfrastructure. Updates the status of the binding. (Overrides BindingManagerBase::UpdateIsBinding().)
Top

  NameDescription
Public eventBindingCompleteOccurs at the completion of a data-binding operation. (Inherited from BindingManagerBase.)
Public eventCurrentChangedOccurs when the currently bound item changes. (Inherited from BindingManagerBase.)
Public eventCurrentItemChangedOccurs when the state of the currently bound item changes. (Inherited from BindingManagerBase.)
Public eventDataErrorOccurs when an Exception is silently handled by the BindingManagerBase. (Inherited from BindingManagerBase.)
Public eventItemChangedOccurs when the current item has been altered.
Public eventListChangedOccurs when the list changes or an item in the list changes.
Public eventMetaDataChangedOccurs when the metadata of the List has changed.
Public eventPositionChangedOccurs after the value of the Position property has changed. (Inherited from BindingManagerBase.)
Top

  NameDescription
Protected fieldfinalTypeInfrastructure. Specifies the data type of the list.
Protected fieldlistpositionInfrastructure. Specifies the current position of the CurrencyManager in the list.
Protected fieldonCurrentChangedHandlerSpecifies the event handler for the CurrentChanged event. (Inherited from BindingManagerBase.)
Protected fieldonPositionChangedHandlerSpecifies the event handler for the PositionChanged event. (Inherited from BindingManagerBase.)
Top

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 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.

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;
   }

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft