Exportar (0) Imprimir
Expandir todo

CurrencyManager.ItemChanged (Evento)

Se produce cuando se ha modificado el elemento actual.

Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)

public event ItemChangedEventHandler ItemChanged
/** @event */
public void add_ItemChanged (ItemChangedEventHandler value)

/** @event */
public void remove_ItemChanged (ItemChangedEventHandler value)

En JScript, se pueden controlar los eventos que define una clase, pero no se pueden definir unos propios.
No aplicable.

El evento ItemChanged se producirá cuando el usuario llame al método ResumeBinding o SuspendBinding.

El evento ItemChanged se produce sólo cuando el elemento en sí ha sido modificado de alguna manera. Por ejemplo, si el valor de un elemento cambia de 10 a 42, se desencadenará el evento. Esto no se debe confundirse con el evento PositionChanged, donde el elemento se ha cambiado por un nuevo elemento.

El evento también se producirá si cambian los datos subyacentes. Por ejemplo, si cambia el valor de DataRowView, se producirá el evento ItemChanged.

NotaNota:

Si va a crear un control propio que utilice el objeto CurrencyManager, deberá utilizar el evento IBindingList.ListChanged en lugar del evento CurrencyManager.ItemChanged. La propiedad ListChangedType del objeto ListChangedEventArgs permite determinar el tipo de acción que se ha producido.

Para obtener más información sobre cómo controlar eventos, vea Utilizar eventos.

En el ejemplo siguiente se agregan controladores de eventos para los eventos ItemChanged y PositionChanged.

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, ""];
    // Add event handlers.
    myCurrencyManager.ItemChanged+=
    new ItemChangedEventHandler(CurrencyManager_ItemChanged);
    myCurrencyManager.PositionChanged+= 
    new EventHandler(CurrencyManager_PositionChanged);
    // Set the initial Position of the control.
    myCurrencyManager.Position = 0;
}
 
private void CurrencyManager_PositionChanged(object sender, System.EventArgs e){
    CurrencyManager myCurrencyManager = (CurrencyManager) sender;
    Console.WriteLine("Position Changed " + myCurrencyManager.Position);
}

private void CurrencyManager_ItemChanged(object sender, System.Windows.Forms.ItemChangedEventArgs e){
    CurrencyManager myCurrencyManager = (CurrencyManager) sender;
    Console.WriteLine("Item Changed " + myCurrencyManager.Position);
}

private void BindControl(DataTable myTable)
{
    // Bind A TextBox control to a DataTable column in a DataSet.
    textBox1.get_DataBindings().Add("Text", myTable, "CompanyName");
    // Specify the CurrencyManager for the DataTable.
    myCurrencyManager = (CurrencyManager)(this.get_BindingContext().
        get_Item(myTable, ""));
    // Add event handlers.
    myCurrencyManager.add_ItemChanged(
        new ItemChangedEventHandler(CurrencyManager_ItemChanged));
    myCurrencyManager.add_PositionChanged(
        new EventHandler(CurrencyManager_PositionChanged));
    // Set the initial Position of the control.
    myCurrencyManager.set_Position(0);
} //BindControl

private void CurrencyManager_PositionChanged(Object sender, 
    System.EventArgs e)
{
    CurrencyManager myCurrencyManager = (CurrencyManager)(sender);
    Console.WriteLine("Position Changed " 
        + myCurrencyManager.get_Position());
} //CurrencyManager_PositionChanged

private void CurrencyManager_ItemChanged(Object sender, 
    System.Windows.Forms.ItemChangedEventArgs e)
{
    CurrencyManager myCurrencyManager = (CurrencyManager)(sender);

    Console.WriteLine("Item Changed " + myCurrencyManager.get_Position());
} //CurrencyManager_ItemChanged

private function BindControl(myTable : 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 = CurrencyManager(this.BindingContext[myTable, ""]);
    // Add event handlers.
    myCurrencyManager.add_ItemChanged(CurrencyManager_ItemChanged);
    myCurrencyManager.add_PositionChanged(CurrencyManager_PositionChanged);
    // Set the initial Position of the control.
    myCurrencyManager.Position = 0;
}
 
private function CurrencyManager_PositionChanged(sender, e : System.EventArgs){
    var myCurrencyManager : CurrencyManager = CurrencyManager(sender);
    Console.WriteLine("Position Changed " + myCurrencyManager.Position);
}

private function CurrencyManager_ItemChanged(sender, e : System.Windows.Forms.ItemChangedEventArgs){
    var myCurrencyManager : CurrencyManager = CurrencyManager(sender);
    Console.WriteLine("Item Changed " + myCurrencyManager.Position);
}

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0, 1.0
Mostrar:
© 2014 Microsoft