Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

CurrencyManager.ItemChanged Event

Occurs when the current item has been altered.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

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

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

JScript supports the use of events, but not the declaration of new ones.

The ItemChanged event will occur when the user calls the ResumeBinding or SuspendBinding method.

The ItemChanged event occurs only when the item itself has been changed in some manner. For example, if the value of an item is changed from 10 to 42, the event will occur. This should not be confused with the PositionChanged event where the item has been changed to a new item.

The event will also occur if the underlying data changes. For example, if you change the value of a DataRowView, the ItemChanged event will occur.

NoteNote

If you are creating your own control that uses the CurrencyManager, you should use the IBindingList.ListChanged instead of the CurrencyManager.ItemChanged event. The ListChangedType property of the ListChangedEventArgs enables you to determine the type of action that has occurred.

For more information about handling events, see Consuming Events.

The following code example adds event handlers for the ItemChanged and PositionChanged events.

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 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.