다음을 통해 공유


BindingManagerBase.PositionChanged 이벤트

정의

Position 속성 값이 변경된 후에 발생합니다.

public:
 event EventHandler ^ PositionChanged;
public event EventHandler PositionChanged;
member this.PositionChanged : EventHandler 
Public Custom Event PositionChanged As EventHandler 

이벤트 유형

예제

다음 코드 예제에서는 를 만든 Binding다음 컨트롤에 대 한 개체의 Binding 컬렉션에 TextBox 추가 합니다. 그런 다음, 데이터 원본에 대한 를 가져오 BindingManagerBase 고 이벤트에 대리자를 추가합니다 PositionChanged .

   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

설명

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상