CurrencyManager.ItemChanged CurrencyManager.ItemChanged CurrencyManager.ItemChanged CurrencyManager.ItemChanged Event

定義

現在の項目が変更されている場合に発生します。Occurs when the current item has been altered.

public:
 event System::Windows::Forms::ItemChangedEventHandler ^ ItemChanged;
public event System.Windows.Forms.ItemChangedEventHandler ItemChanged;
member this.ItemChanged : System.Windows.Forms.ItemChangedEventHandler 
Public Custom Event ItemChanged As ItemChangedEventHandler 

次のコード例は、イベント ハンドラーを追加、ItemChangedPositionChangedイベント。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 );
}

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 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)
    ' Add event handlers.
    AddHandler myCurrencyManager.ItemChanged, AddressOf CurrencyManager_ItemChanged
    AddHandler myCurrencyManager.PositionChanged, AddressOf CurrencyManager_PositionChanged
    ' Set the initial Position of the control.
    myCurrencyManager.Position = 0
End Sub 'BindControl


Private Sub CurrencyManager_PositionChanged(sender As Object, e As System.EventArgs)
    Dim myCurrencyManager As CurrencyManager = CType(sender, CurrencyManager)
    Console.WriteLine(("Position Changed " & myCurrencyManager.Position))
End Sub 'CurrencyManager_PositionChanged


Private Sub CurrencyManager_ItemChanged(sender As Object, e As System.Windows.Forms.ItemChangedEventArgs)
    Dim myCurrencyManager As CurrencyManager = CType(sender, CurrencyManager)
    Console.WriteLine(("Item Changed " & myCurrencyManager.Position))
End Sub 'CurrencyManager_ItemChanged

注釈

ItemChangedユーザーを呼び出すときにイベントが発生、ResumeBindingまたはSuspendBindingメソッド。The ItemChanged event will occur when the user calls the ResumeBinding or SuspendBinding method.

ItemChangedだけ、項目自体が変更されたときの何らかの方法でイベントが発生します。The ItemChanged event occurs only when the item itself has been changed in some manner. たとえば、項目の値は、42 に 10 から変更される、イベントが発生します。For example, if the value of an item is changed from 10 to 42, the event will occur. これと混同しないで、PositionChangedイベントを新しい項目に、項目が変更された場所。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. 値を変更する場合など、 DataRowViewItemChangedイベントが発生します。For example, if you change the value of a DataRowView, the ItemChanged event will occur.

注意

使用する独自のコントロールを作成する場合、 CurrencyManager、使用する必要があります、IBindingList.ListChangedの代わりに、CurrencyManager.ItemChangedイベント。If you are creating your own control that uses the CurrencyManager, you should use the IBindingList.ListChanged instead of the CurrencyManager.ItemChanged event. ListChangedTypeのプロパティ、ListChangedEventArgsが発生したアクションの種類を決定することができます。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.

適用対象

こちらもご覧ください