Export (0) Print
Expand All
Expand Minimize

DataRowChangeEventHandler Delegate

Represents the method that will handle the RowChanging, RowChanged, RowDeleting, and RowDeleted events of a DataTable.

[Visual Basic]
<Serializable>
Public Delegate Sub DataRowChangeEventHandler( _
   ByVal sender As Object, _
   ByVal e As DataRowChangeEventArgs _
)
[C#]
[Serializable]
public delegate void DataRowChangeEventHandler(
   object sender,
   DataRowChangeEventArgs e
);
[C++]
[Serializable]
public __gc __delegate void DataRowChangeEventHandler(
   Object* sender,
   DataRowChangeEventArgs* e
);

[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [Visual Basic, C#, C++]

The declaration of your event handler must have the same parameters as the DataRowChangeEventHandler delegate declaration.

sender
The source of the event.
e
A DataRowChangeEventArgs that contains the event data.

Remarks

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 Events and Delegates.

Example

[Visual Basic, C#, C++] 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.

[Visual Basic] 
Private myDataTable As DataTable    
   
Private Sub [AddHandler]()
    myDataTable = New DataTable("myDataTable")
    AddHandler myDataTable.RowChanged, AddressOf myDataTable_Changed
End Sub    
   
Protected Sub myDataTable_Changed _
(sender As Object, e As System.Data.DataRowChangeEventArgs)

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

[C#] 
private DataTable myDataTable;

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

protected void myDataTable_Changed(object sender,
System.Data.DataRowChangeEventArgs e) { 
   Console.WriteLine("Row Changed", e.Action,
      e.Row[dataGrid1.CurrentCell.ColumnNumber]);
}

[C++] 
private:
 DataTable* myDataTable;
 
 void AddHandler(){
    myDataTable = new DataTable(S"myDataTable");
    myDataTable->RowChanged +=
       new System::Data::DataRowChangeEventHandler(this, &Form1::myDataTable_Changed);
 }
 
protected:
 void myDataTable_Changed(Object* /*sender*/, DataRowChangeEventArgs* e) { 
    Console::WriteLine(S"Row Changed", __box(e->Action),
       e->Row->Item[dataGrid1->CurrentCell.ColumnNumber]);
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Data (in System.Data.dll)

See Also

System.Data Namespace | DataRow | DataTable | DataRowChangeEventArgs

Show:
© 2014 Microsoft