The AddingDataRow event is raised when a new data row is about to be added to the grid. It allows you to provide data manually to the row's cells or to modify the data being read from the data source.
Basic steps - C#
To subscribe to the AddingDataRow event, the following steps must be performed:
Dim random As New Random() ' This method will handle the AddingDataRow events that are raised. Private Sub grid_AddingDataRow( ByVal sender As Object, ByVal e As AddingDataRowEventArgs ) Try Dim cell As DataCell For Each cell in e.DataRow.Cells cell.Value = random.Next().ToString() Next cell Catch exception As Exception MessageBox.Show( exception.ToString() ) End Try End Sub
' If you no longer wish to handle the AddingDataRow events that are raised, ' you can unsubscribe from the event notification by doing the following:
gridControl1.AddingDataRow += new AddingDataRowEventHandler( this.grid_AddingDataRow );
Random random = new Random(); // This method will handle the AddingDataRow events that are raised. private void grid_AddingDataRow( object sender, AddingDataRowEventArgs e ) { try { foreach( DataCell cell in e.DataRow.Cells ) { cell.Value = random.Next().ToString(); } } catch( Exception exception ) { MessageBox.Show( exception.ToString ); } }