CurrencyManager CurrencyManager CurrencyManager CurrencyManager Class

Definición

Administra una lista de objetos Binding.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
Herencia

Ejemplos

El siguiente código de ejemplo se enlaza un TextBox control a una columna de un DataTable, obtiene el CurrencyManager para el enlace y establece su posición.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

Comentarios

El CurrencyManager deriva la BindingManagerBase clase.The CurrencyManager derives from the BindingManagerBase class. Use la BindingContext para devolver un CurrencyManager o PropertyManager.Use the BindingContext to return either a CurrencyManager or a PropertyManager. El objeto real devuelto depende del origen de datos y miembro de datos pasa a la Item[Object] propiedad de la BindingContext.The actual object returned depends on the data source and data member passed to the Item[Object] property of the BindingContext. Si el origen de datos es un objeto que puede devolver una sola propiedad (en lugar de una lista de objetos), el tipo será un PropertyManager.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. Por ejemplo, si especifica un TextBox como origen de datos, un PropertyManager se devolverá.For example, if you specify a TextBox as the data source, a PropertyManager will be returned. Si, por otro lado, el origen de datos es un objeto que implementa el IList, IListSource, o IBindingList interfaz, un CurrencyManager se devolverá.If, on the other hand, the data source is an object that implements the IList, IListSource, or IBindingList interface, a CurrencyManager will be returned.

El Current propiedad devuelve el elemento actual en la lista subyacente.The Current property returns the current item in the underlying list. Para cambiar el elemento actual, establezca el Position propiedad a un nuevo valor.To change the current item, set the Position property to a new value. El valor debe ser mayor que 0 y debe ser menor que el valor de la Count propiedad.The value must be greater than 0 and must be less than the value of the Count property.

Si el origen de datos subyacente implementa el IBindingList interfaz y el AllowNew propiedad está establecida en true, puede usar el AddNew método.If the underlying data source implements the IBindingList interface, and the AllowNew property is set to true, you can use the AddNew method.

Campos

finalType finalType finalType finalType

Especifica el tipo de datos de la lista.Specifies the data type of the list.

listposition listposition listposition listposition

Especifica la posición actual del objeto CurrencyManager en la lista.Specifies the current position of the CurrencyManager in the list.

onCurrentChangedHandler onCurrentChangedHandler onCurrentChangedHandler onCurrentChangedHandler

Especifica el controlador de eventos para el evento CurrentChanged.Specifies the event handler for the CurrentChanged event.

(Inherited from BindingManagerBase)
onPositionChangedHandler onPositionChangedHandler onPositionChangedHandler onPositionChangedHandler

Especifica el controlador de eventos para el evento PositionChanged.Specifies the event handler for the PositionChanged event.

(Inherited from BindingManagerBase)

Propiedades

Bindings Bindings Bindings Bindings

Obtiene la colección de enlaces que se administra.Gets the collection of bindings being managed.

(Inherited from BindingManagerBase)
Count Count Count Count

Obtiene el número de elementos de la lista.Gets the number of items in the list.

Current Current Current Current

Obtiene el elemento actual de la lista.Gets the current item in the list.

IsBindingSuspended IsBindingSuspended IsBindingSuspended IsBindingSuspended

Obtiene un valor que indica si el enlace se ha suspendido.Gets a value indicating whether binding is suspended.

(Inherited from BindingManagerBase)
List List List List

Obtiene la ruta de acceso para CurrencyManager.Gets the list for this CurrencyManager.

Position Position Position Position

Obtiene o establece la posición en la que se encuentra dentro de la listaGets or sets the position you are at within the list.

Métodos

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

Agrega un nuevo elemento a la lista subyacente.Adds a new item to the underlying list.

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

Cancela la operación de edición actual.Cancels the current edit operation.

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

Produce una excepción si no hay ninguna lista o la lista está vacía.Throws an exception if there is no list, or the list is empty.

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

Termina la operación de edición actual.Ends the current edit operation.

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

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

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

Sirve como la función hash predeterminada.Serves as the default hash function.

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

Obtiene la colección de descriptores de propiedades de la lista subyacente.Gets the property descriptor collection for the underlying list.

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

Obtiene la colección de descriptores de propiedades para el enlace con el objeto ArrayList especificado.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)

Obtiene la lista de propiedades de los elementos administrados por BindingManagerBase.Gets the list of properties of the items managed by this BindingManagerBase.

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

Obtiene el nombre de la lista que proporciona los datos para el enlace que utiliza el conjunto de propiedades enlazadas especificado.Gets the name of the list supplying the data for the binding using the specified set of bound properties.

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

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

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

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

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

Genera el evento BindingComplete.Raises the BindingComplete event.

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

Genera el evento CurrentChanged.Raises the CurrentChanged event.

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

Genera el evento CurrentItemChanged.Raises the CurrentItemChanged event.

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

Genera el evento DataError.Raises the DataError event.

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

Genera el evento ItemChanged.Raises the ItemChanged event.

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

Genera el evento MetaDataChanged.Raises the MetaDataChanged event.

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

Genera el evento PositionChanged.Raises the PositionChanged event.

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

Extrae datos del control con enlace a datos y los aplica al origen de datos, y no devuelve ninguna información.Pulls data from the data-bound control into the data source, returning no information.

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

Extrae datos del origen de datos en el control con enlace a datos, y no devuelve ninguna información.Pushes data from the data source into the data-bound control, returning no information.

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

Hace que la lista enlazada a datos vuelva a llenarse.Forces a repopulation of the data-bound list.

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

Quita el elemento en el índice especificado.Removes the item at the specified index.

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

Reanuda el enlace de datos.Resumes data binding.

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

Suspende el enlace de datos para evitar que los cambios actualicen el origen de datos enlazado.Suspends data binding to prevents changes from updating the bound data source.

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

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

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

Actualiza el estado del enlace.Updates the status of the binding.

Eventos

BindingComplete BindingComplete BindingComplete BindingComplete

Se produce cuando finaliza una operación de enlace de datos.Occurs at the completion of a data-binding operation.

(Inherited from BindingManagerBase)
CurrentChanged CurrentChanged CurrentChanged CurrentChanged

Se produce cuando cambia el elemento enlazado actualmente.Occurs when the currently bound item changes.

(Inherited from BindingManagerBase)
CurrentItemChanged CurrentItemChanged CurrentItemChanged CurrentItemChanged

Se produce cuando el estado del elemento enlazado actualmente cambia.Occurs when the state of the currently bound item changes.

(Inherited from BindingManagerBase)
DataError DataError DataError DataError

Se produce cuando Exception controla silenciosamente BindingManagerBase.Occurs when an Exception is silently handled by the BindingManagerBase.

(Inherited from BindingManagerBase)
ItemChanged ItemChanged ItemChanged ItemChanged

Se produce cuando se ha modificado el elemento actual.Occurs when the current item has been altered.

ListChanged ListChanged ListChanged ListChanged

Se produce cuando cambia la lista o un elemento de la lista.Occurs when the list changes or an item in the list changes.

MetaDataChanged MetaDataChanged MetaDataChanged MetaDataChanged

Se produce cuando los metadatos de List han cambiado.Occurs when the metadata of the List has changed.

PositionChanged PositionChanged PositionChanged PositionChanged

Se produce después de haber cambiado el valor de la propiedad Position.Occurs after the value of the Position property has changed.

(Inherited from BindingManagerBase)

Se aplica a

Consulte también: