Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 PositionChanged Event

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
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)
Visual Basic (Declaration)
Public Event PositionChanged As EventHandler
Visual Basic (Usage)
Dim instance As BindingManagerBase
Dim handler As EventHandler

AddHandler instance.PositionChanged, handler
C#
public event EventHandler PositionChanged
Visual C++
public:
 event EventHandler^ PositionChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
JScript
JScript does not support events.

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.

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

C#
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);
}


Visual C++
   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 );
   }


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

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker