CurrencyManager.ItemChanged Evento
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Se produce cuando se ha modificado el elemento actual.
public:
event System::Windows::Forms::ItemChangedEventHandler ^ ItemChanged;
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
Tipo de evento
Ejemplos
En el ejemplo de código siguiente se agregan controladores de eventos para los ItemChanged eventos y PositionChanged .
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
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
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
Comentarios
El ItemChanged evento se producirá cuando el usuario llame al ResumeBinding método o SuspendBinding .
El ItemChanged evento solo se produce cuando el propio elemento se ha cambiado de alguna manera. Por ejemplo, si el valor de un elemento se cambia de 10 a 42, se producirá el evento. Esto no debe confundirse con el evento en el PositionChanged que el elemento se ha cambiado a un nuevo elemento.
El evento también se producirá si cambian los datos subyacentes. Por ejemplo, si cambia el valor de , DataRowViewse producirá el ItemChanged evento .
Nota
Si va a crear su propio control que usa CurrencyManager, debe usar en IBindingList.ListChanged lugar del CurrencyManager.ItemChanged evento . La ListChangedType propiedad de ListChangedEventArgs permite determinar el tipo de acción que se ha producido.
Para obtener más información sobre el manejo de eventos, consulte controlar y provocar eventos.