CurrencyManager.ItemChanged 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在当前项更改后发生。
public:
event System::Windows::Forms::ItemChangedEventHandler ^ ItemChanged;
public event System.Windows.Forms.ItemChangedEventHandler ItemChanged;
public event System.Windows.Forms.ItemChangedEventHandler? ItemChanged;
member this.ItemChanged : System.Windows.Forms.ItemChangedEventHandler
Public Custom Event ItemChanged As ItemChangedEventHandler
事件类型
示例
下面的代码示例为 ItemChanged 和 PositionChanged 事件添加事件处理程序。
void BindControl( DataTable^ myTable )
{
// Bind A TextBox control to a DataTable column in a DataSet.
textBox1->DataBindings->Add( "Text", myTable, "CompanyName" );
// Specify the CurrencyManager for the DataTable.
myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[myTable, ""]);
// Add event handlers.
myCurrencyManager->ItemChanged += gcnew ItemChangedEventHandler( this, &Form1::CurrencyManager_ItemChanged );
myCurrencyManager->PositionChanged += gcnew EventHandler( this, &Form1::CurrencyManager_PositionChanged );
// Set the initial Position of the control.
myCurrencyManager->Position = 0;
}
void CurrencyManager_PositionChanged( Object^ sender, System::EventArgs^ /*e*/ )
{
CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(sender);
Console::WriteLine( "Position Changed {0}", myCurrencyManager->Position );
}
void CurrencyManager_ItemChanged( Object^ sender, System::Windows::Forms::ItemChangedEventArgs^ /*e*/ )
{
CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(sender);
Console::WriteLine( "Item Changed {0}", myCurrencyManager->Position );
}
private void BindControl(DataTable myTable)
{
// Bind A TextBox control to a DataTable column in a DataSet.
textBox1.DataBindings.Add("Text", myTable, "CompanyName");
// Specify the CurrencyManager for the DataTable.
myCurrencyManager = (CurrencyManager)this.BindingContext[myTable, ""];
// Add event handlers.
myCurrencyManager.ItemChanged+=
new ItemChangedEventHandler(CurrencyManager_ItemChanged);
myCurrencyManager.PositionChanged+=
new EventHandler(CurrencyManager_PositionChanged);
// Set the initial Position of the control.
myCurrencyManager.Position = 0;
}
private void CurrencyManager_PositionChanged(object sender, System.EventArgs e){
CurrencyManager myCurrencyManager = (CurrencyManager) sender;
Console.WriteLine("Position Changed " + myCurrencyManager.Position);
}
private void CurrencyManager_ItemChanged(object sender, System.Windows.Forms.ItemChangedEventArgs e){
CurrencyManager myCurrencyManager = (CurrencyManager) sender;
Console.WriteLine("Item Changed " + myCurrencyManager.Position);
}
Private Sub BindControl(myTable As DataTable)
' Bind A TextBox control to a DataTable column in a DataSet.
textBox1.DataBindings.Add("Text", myTable, "CompanyName")
' Specify the CurrencyManager for the DataTable.
myCurrencyManager = CType(Me.BindingContext(myTable, ""), CurrencyManager)
' Add event handlers.
AddHandler myCurrencyManager.ItemChanged, AddressOf CurrencyManager_ItemChanged
AddHandler myCurrencyManager.PositionChanged, AddressOf CurrencyManager_PositionChanged
' Set the initial Position of the control.
myCurrencyManager.Position = 0
End Sub
Private Sub CurrencyManager_PositionChanged(sender As Object, e As System.EventArgs)
Dim myCurrencyManager As CurrencyManager = CType(sender, CurrencyManager)
Console.WriteLine(("Position Changed " & myCurrencyManager.Position))
End Sub
Private Sub CurrencyManager_ItemChanged(sender As Object, e As System.Windows.Forms.ItemChangedEventArgs)
Dim myCurrencyManager As CurrencyManager = CType(sender, CurrencyManager)
Console.WriteLine(("Item Changed " & myCurrencyManager.Position))
End Sub
注解
当用户ItemChanged调用 或 SuspendBinding 方法时,ResumeBinding将发生 该事件。
ItemChanged仅当以某种方式更改了项本身时,才会发生该事件。 例如,如果项的值从 10 更改为 42,则会发生 该事件。 这不应与 PositionChanged 项已更改为新项的事件混淆。
如果基础数据发生更改,也会发生 该事件。 例如,如果更改 的值 DataRowView,将发生 事件 ItemChanged 。
注意
如果要创建自己的使用 的 CurrencyManager控件,则应使用 IBindingList.ListChanged 而不是 CurrencyManager.ItemChanged 事件。 的 ListChangedType 属性 ListChangedEventArgs 可用于确定已发生的操作类型。
有关处理事件的详细信息,请参阅 处理和引发事件。