BindingManagerBase.PositionChanged 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生於 Position 屬性的值已變更後。
public:
event EventHandler ^ PositionChanged;
public event EventHandler PositionChanged;
member this.PositionChanged : EventHandler
Public Custom Event PositionChanged As EventHandler
事件類型
範例
下列程式碼範例會 Binding 建立 ,然後將它新增至 控制項的物件 BindingTextBox 集合。 然後,此範例會取得 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
備註
如需處理事件的詳細資訊,請參閱 處理和引發事件。