Export (0) Print
Expand All

BindingManagerBase.PositionChanged Event

Occurs after the value of the Position property has changed.

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

public event EventHandler PositionChanged
/** @event */
public void add_PositionChanged (EventHandler value)

/** @event */
public void remove_PositionChanged (EventHandler value)

JScript supports the use of events, but not the declaration of new ones.

For more information about handling events, see Consuming Events.

The following code example creates a Binding, and then adds it to a collection of Binding objects for a TextBox control. The example then gets the BindingManagerBase for the data source and adds a delegate to the PositionChanged event.

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft