CurrencyManager Class
TOC
Collapse the table of content
Expand the table of content

CurrencyManager Class

 

Manages a list of Binding objects.

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

System.Object
  System.Windows.Forms.BindingManagerBase
    System.Windows.Forms.CurrencyManager

public class CurrencyManager : BindingManagerBase

NameDescription
System_CAPS_pubpropertyBindings

Gets the collection of bindings being managed.(Inherited from BindingManagerBase.)

System_CAPS_pubpropertyCount

Gets the number of items in the list.(Overrides BindingManagerBase.Count.)

System_CAPS_pubpropertyCurrent

Gets the current item in the list.(Overrides BindingManagerBase.Current.)

System_CAPS_pubpropertyIsBindingSuspended

Gets a value indicating whether binding is suspended.(Inherited from BindingManagerBase.)

System_CAPS_pubpropertyList

Gets the list for this CurrencyManager.

System_CAPS_pubpropertyPosition

Gets or sets the position you are at within the list.(Overrides BindingManagerBase.Position.)

NameDescription
System_CAPS_pubmethodAddNew()

Adds a new item to the underlying list.(Overrides BindingManagerBase.AddNew().)

System_CAPS_pubmethodCancelCurrentEdit()

Cancels the current edit operation.(Overrides BindingManagerBase.CancelCurrentEdit().)

System_CAPS_protmethodCheckEmpty()

This API supports the product infrastructure and is not intended to be used directly from your code. Throws an exception if there is no list, or the list is empty.

System_CAPS_pubmethodEndCurrentEdit()

Ends the current edit operation.(Overrides BindingManagerBase.EndCurrentEdit().)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetItemProperties()

Gets the property descriptor collection for the underlying list.(Overrides BindingManagerBase.GetItemProperties().)

System_CAPS_protmethodGetItemProperties(ArrayList, ArrayList)

Gets the collection of property descriptors for the binding using the specified ArrayList.(Inherited from BindingManagerBase.)

System_CAPS_protmethodGetItemProperties(Type, Int32, ArrayList, ArrayList)

Gets the list of properties of the items managed by this BindingManagerBase.(Inherited from BindingManagerBase.)

System_CAPS_protmethodGetListName(ArrayList)

Gets the name of the list supplying the data for the binding using the specified set of bound properties.(Overrides BindingManagerBase.GetListName(ArrayList).)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnBindingComplete(BindingCompleteEventArgs)

Raises the BindingComplete event. (Inherited from BindingManagerBase.)

System_CAPS_protmethodOnCurrentChanged(EventArgs)
System_CAPS_protmethodOnCurrentItemChanged(EventArgs)
System_CAPS_protmethodOnDataError(Exception)

Raises the DataError event.(Inherited from BindingManagerBase.)

System_CAPS_protmethodOnItemChanged(ItemChangedEventArgs)

Raises the ItemChanged event.

System_CAPS_protmethodOnMetaDataChanged(EventArgs)

Raises the MetaDataChanged event.

System_CAPS_protmethodOnPositionChanged(EventArgs)

Raises the PositionChanged event.

System_CAPS_protmethodPullData()

Pulls data from the data-bound control into the data source, returning no information.(Inherited from BindingManagerBase.)

System_CAPS_protmethodPushData()

Pushes data from the data source into the data-bound control, returning no information.(Inherited from BindingManagerBase.)

System_CAPS_pubmethodRefresh()

Forces a repopulation of the data-bound list.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the item at the specified index.(Overrides BindingManagerBase.RemoveAt(Int32).)

System_CAPS_pubmethodResumeBinding()

Resumes data binding.(Overrides BindingManagerBase.ResumeBinding().)

System_CAPS_pubmethodSuspendBinding()

Suspends data binding to prevents changes from updating the bound data source.(Overrides BindingManagerBase.SuspendBinding().)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_protmethodUpdateIsBinding()

This API supports the product infrastructure and is not intended to be used directly from your code. Updates the status of the binding.(Overrides BindingManagerBase.UpdateIsBinding().)

NameDescription
System_CAPS_protfieldfinalType

This API supports the product infrastructure and is not intended to be used directly from your code. Specifies the data type of the list.

System_CAPS_protfieldlistposition

This API supports the product infrastructure and is not intended to be used directly from your code. Specifies the current position of the CurrencyManager in the list.

System_CAPS_protfieldonCurrentChangedHandler

Specifies the event handler for the CurrentChanged event.(Inherited from BindingManagerBase.)

System_CAPS_protfieldonPositionChangedHandler

Specifies the event handler for the PositionChanged event.(Inherited from BindingManagerBase.)

NameDescription
System_CAPS_pubeventBindingComplete

Occurs at the completion of a data-binding operation.(Inherited from BindingManagerBase.)

System_CAPS_pubeventCurrentChanged

Occurs when the currently bound item changes.(Inherited from BindingManagerBase.)

System_CAPS_pubeventCurrentItemChanged

Occurs when the state of the currently bound item changes.(Inherited from BindingManagerBase.)

System_CAPS_pubeventDataError

Occurs when an Exception is silently handled by the BindingManagerBase. (Inherited from BindingManagerBase.)

System_CAPS_pubeventItemChanged

Occurs when the current item has been altered.

System_CAPS_pubeventListChanged

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

System_CAPS_pubeventMetaDataChanged

Occurs when the metadata of the List has changed.

System_CAPS_pubeventPositionChanged

Occurs after the value of the Position property has changed.(Inherited from BindingManagerBase.)

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.

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

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft