BindingManagerBase.PositionChanged 事件
在 Position 属性的值更改后发生。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Event PositionChanged As EventHandler
用法
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 支持使用事件,但不支持进行新的声明。
备注
有关处理事件的更多信息,请参见 使用事件。
示例
下面的代码示例创建一个 Binding,然后将其添加到 TextBox 控件的 Binding 对象的集合中。然后该示例获取数据源的 BindingManagerBase,并向 PositionChanged 事件添加一个委托。
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
平台
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
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0
请参见
参考
BindingManagerBase 类
BindingManagerBase 成员
System.Windows.Forms 命名空间