Freigeben über


BindingManagerBase.PositionChanged-Ereignis

Tritt ein, nachdem sich der Wert der Position-Eigenschaft geändert hat.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Event PositionChanged As EventHandler
'Usage
Dim instance As BindingManagerBase
Dim handler As EventHandler

AddHandler instance.PositionChanged, handler
public event EventHandler PositionChanged
public:
event EventHandler^ PositionChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public void add_PositionChanged (EventHandler value)

/** @event */
public void remove_PositionChanged (EventHandler value)
JScript unterstützt die Verwendung von Ereignissen, aber nicht die Deklaration von neuen Ereignissen.

Hinweise

Weitere Informationen zur Behandlung von Ereignissen finden Sie unter Behandeln von Ereignissen.

Beispiel

Im folgenden Codebeispiel wird eine Binding erzeugt und anschließend einer Auflistung von Binding-Objekten für ein TextBox-Steuerelement hinzugefügt. Danach wird im Beispiel die BindingManagerBase für die Datenquelle abgerufen und dem PositionChanged-Ereignis ein Delegat hinzugefügt.

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 'BindControl


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 'Position_Changed
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);
}
   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.get_DataBindings().Add(myBinding);

    // Get the BindingManagerBase for the Customers table. 
    BindingManagerBase bmCustomers =  
        this.get_BindingContext().get_Item(ds, "Customers");

    // Add the delegate for the PositionChanged event.
    bmCustomers.add_PositionChanged(new EventHandler(Position_Changed));
} //BindControl

private void Position_Changed(Object sender, EventArgs e)
{
    // Print the Position property value when it changes.
    Console.WriteLine(((BindingManagerBase)(sender)).get_Position());
} //Position_Changed

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

BindingManagerBase-Klasse
BindingManagerBase-Member
System.Windows.Forms-Namespace