Export (0) Print
Expand All

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 {
	void add (ItemChangedEventHandler^ value);
	void remove (ItemChangedEventHandler^ value);
}

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 Handling and Raising Events.

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

   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 = dynamic_cast<CurrencyManager^>(this->BindingContext[myTable, ""]);

      // Add event handlers.
      myCurrencyManager->ItemChanged += gcnew ItemChangedEventHandler( this, &Form1::CurrencyManager_ItemChanged );
      myCurrencyManager->PositionChanged += gcnew EventHandler( this, &Form1::CurrencyManager_PositionChanged );

      // Set the initial Position of the control.
      myCurrencyManager->Position = 0;
   }

   void CurrencyManager_PositionChanged( Object^ sender, System::EventArgs^ /*e*/ )
   {
      CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(sender);
      Console::WriteLine( "Position Changed {0}", myCurrencyManager->Position );
   }

   void CurrencyManager_ItemChanged( Object^ sender, System::Windows::Forms::ItemChangedEventArgs^ /*e*/ )
   {
      CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(sender);
      Console::WriteLine( "Item Changed {0}", myCurrencyManager->Position );
   }

.NET Framework

Supported in: 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.

Show:
© 2014 Microsoft