CurrencyManager.ItemChanged-Ereignis
Tritt ein, wenn das aktuelle Element geändert wurde.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Event ItemChanged As ItemChangedEventHandler
'Usage
Dim instance As CurrencyManager
Dim handler As ItemChangedEventHandler
AddHandler instance.ItemChanged, handler
public event ItemChangedEventHandler ItemChanged
public:
event ItemChangedEventHandler^ ItemChanged {
void add (ItemChangedEventHandler^ value);
void remove (ItemChangedEventHandler^ value);
}
/** @event */
public void add_ItemChanged (ItemChangedEventHandler value)
/** @event */
public void remove_ItemChanged (ItemChangedEventHandler value)
JScript unterstützt die Verwendung von Ereignissen, aber nicht die Deklaration von neuen Ereignissen.
Hinweise
Das ItemChanged-Ereignis tritt ein, wenn der Benutzer die ResumeBinding-Methode oder die SuspendBinding-Methode aufruft.
Das ItemChanged-Ereignis tritt nur ein, wenn das Element selbst auf irgendeine Weise geändert wurde. Wenn der Wert eines Elements beispielsweise von 10 in 42 geändert wird, tritt das Ereignis ein. Dies darf nicht mit dem PositionChanged-Ereignis gleichgesetzt werden, bei dem das Element in ein neues Element geändert wurde.
Das Ereignis tritt auch ein, wenn die zugrunde liegenden Daten geändert werden. Wenn Sie z. B. den Wert einer DataRowView ändern, tritt das ItemChanged-Ereignis ein.
Hinweis
Wenn Sie ein eigenes Steuerelement erstellen, in dem der CurrencyManager verwendet wird, müssen Sie das IBindingList.ListChanged-Ereignis anstelle des CurrencyManager.ItemChanged-Ereignisses verwenden. Mit der ListChangedType-Eigenschaft von ListChangedEventArgs können Sie den Typ der erfolgten Aktion bestimmen.
Weitere Informationen zum Behandeln von Ereignissen finden Sie unter Behandeln von Ereignissen.
Beispiel
Im folgenden Codebeispiel werden Ereignishandler für das ItemChanged-Ereignis und das PositionChanged-Ereignis hinzugefügt.
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
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);
}
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.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);
}
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
CurrencyManager-Klasse
CurrencyManager-Member
System.Windows.Forms-Namespace
BindingManagerBase.PositionChanged-Ereignis