BindingManagerBase.PositionChanged 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 después de haber cambiado el valor de la propiedad Position.
public:
event EventHandler ^ PositionChanged;
public event EventHandler PositionChanged;
member this.PositionChanged : EventHandler
Public Custom Event PositionChanged As EventHandler
Tipo de evento
Ejemplos
En el ejemplo de código siguiente se crea un Bindingy, a continuación, se agrega a una colección de Binding objetos para un TextBox control . A continuación, el ejemplo obtiene para BindingManagerBase el origen de datos y agrega un delegado al PositionChanged evento .
void BindControl()
{
/* Create a Binding object for the TextBox control.
The data-bound property for the control is the Text
property. */
Binding^ myBinding = gcnew Binding( "Text",ds,"customers.custName" );
text1->DataBindings->Add( myBinding );
// Get the BindingManagerBase for the Customers table.
BindingManagerBase^ bmCustomers = this->BindingContext[ ds,"Customers" ];
// Add the delegate for the PositionChanged event.
bmCustomers->PositionChanged += gcnew EventHandler( this, &Form1::Position_Changed );
}
private:
void Position_Changed( Object^ sender, EventArgs^ /*e*/ )
{
// Print the Position property value when it changes.
Console::WriteLine( (dynamic_cast<BindingManagerBase^>(sender))->Position );
}
protected void BindControl()
{
/* Create a Binding object for the TextBox control.
The data-bound property for the control is the Text
property. */
Binding myBinding =
new Binding("Text", ds, "customers.custName");
text1.DataBindings.Add(myBinding);
// Get the BindingManagerBase for the Customers table.
BindingManagerBase bmCustomers =
this.BindingContext [ds, "Customers"];
// Add the delegate for the PositionChanged event.
bmCustomers.PositionChanged +=
new EventHandler(Position_Changed);
}
private void Position_Changed(object sender, EventArgs e)
{
// Print the Position property value when it changes.
Console.WriteLine(((BindingManagerBase)sender).Position);
}
Protected Sub BindControl()
' Create a Binding object for the TextBox control.
' The data-bound property for the control is the Text
' property.
Dim myBinding As New Binding("Text", ds, "customers.custName")
text1.DataBindings.Add(myBinding)
' Get the BindingManagerBase for the Customers table.
Dim bmCustomers As BindingManagerBase = Me.BindingContext(ds, "Customers")
' Add the delegate for the PositionChanged event.
AddHandler bmCustomers.PositionChanged, AddressOf Position_Changed
End Sub
Private Sub Position_Changed(sender As Object, e As EventArgs)
' Print the Position property value when it changes.
Console.WriteLine(CType(sender, BindingManagerBase).Position)
End Sub
Comentarios
Para obtener más información sobre el manejo de eventos, consulte controlar y provocar eventos.