ColumnChanging
DataColumnChangeEventHandler ColumnChanging;
The ColumnChanging
event is raised when the value
for column in the DataRow
is being changed.
The following code demonstrates how to handle the
ColumnChanging
event:
DataTable dt = new DataTable(); dt.ColumnChanging += new DataColumnChangeEventHandler(dt_ColumnChanging); private void dt_ColumnChanging(object sender, DataColumnChangeEventArgs e) { MessageBox.Show("ColumnChanging: Name = " + e.Column.ColumnName + "; " + "ProposedValue = " + e.ProposedValue.ToString() + "; " + "Row Id = " + e.Row["Id"].ToString()); }
The event handler receives an argument of type
DataColumnChangeEventArgs
, which contains
properties that provide specific information about the event as
described in Table 23-13.