DataRowChangeEventHandler 委托

定义

表示将处理 RowChangingRowChangedRowDeletingRowDeletedDataTable 事件的方法。Represents the method that will handle the RowChanging, RowChanged, RowDeleting, and RowDeleted events of a DataTable.

public delegate void DataRowChangeEventHandler(System::Object ^ sender, DataRowChangeEventArgs ^ e);
public delegate void DataRowChangeEventHandler(object sender, DataRowChangeEventArgs e);
type DataRowChangeEventHandler = delegate of obj * DataRowChangeEventArgs -> unit
Public Delegate Sub DataRowChangeEventHandler(sender As Object, e As DataRowChangeEventArgs)

参数

sender
Object

事件源。The source of the event.

e
DataRowChangeEventArgs

包含事件数据的 DataRowChangeEventArgsA DataRowChangeEventArgs that contains the event data.

继承
DataRowChangeEventHandler

示例

下面的示例添加了DataRowChangeEventHandler一个和一个过程, 用于在行发生更改时处理事件。The following example adds a DataRowChangeEventHandler and the procedure to handle the event when a row is changed. 此过程将打印已更改行的操作和值。The procedure prints the action and value of the changed row.

private DataTable dataTable;

private void AddHandler(){
   dataTable = new DataTable("dataTable");
   dataTable.RowChanged +=
      new System.Data.DataRowChangeEventHandler(dataTable_Changed);
}

private void dataTable_Changed(object sender,
System.Data.DataRowChangeEventArgs e) 
{ 
   Console.WriteLine("Row Changed", e.Action,
      e.Row[dataGrid1.CurrentCell.ColumnNumber]);
}
Private dataTable As DataTable    
   
Private Sub [AddHandler]()
    dataTable = New DataTable("dataTable")
    AddHandler dataTable.RowChanged, AddressOf dataTable_Changed
End Sub    
   
Private Sub dataTable_Changed _
   (sender As Object, e As System.Data.DataRowChangeEventArgs)

    Console.WriteLine("Row Changed", e.Action, _
       e.Row(dataGrid1.CurrentCell.ColumnNumber))
End Sub

注解

创建 DataRowChangeEventHandler 委托时,需要标识将处理该事件的方法。When you create a DataRowChangeEventHandler delegate, you identify the method that will handle the event. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 事件发生时, 将调用事件处理程序, 直到删除委托。The event handler is called whenever the event occurs, until you remove the delegate. 有关委托的详细信息, 请参阅处理和引发事件For more information about delegates, see Handling and Raising Events.

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于

另请参阅