DataGridView.RowsAdded Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Occurs after a new row is added to the DataGridView.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member RowsAdded : IEvent<DataGridViewRowsAddedEventHandler,

Rows in the control are not automatically sorted when new rows are added. To sort new rows into their correct position, call the Sort method in a RowsAdded event handler.

When the user adds a new row using the row for new records, the DataGridViewRowsAddedEventArgs.RowIndex value in the handler for this event is equal to the index of the new location of the row for new records, which is one greater than the row just added. When you add rows programmatically, however, the RowIndex value is the index of the first row added.

In virtual mode, this event occurs before the CellValuePushed event and can be used to create new records in your data store that you can then populate in the CellValuePushed event handler.

For more information about handling events, see NIB: Consuming Events.

The following code example handles the RowsAdded event to increment the number of rows in a virtual DataGridView. The number of rows is used in the CellValueNeeded handler so it knows when to show a blank cell versus an initialized cell for a new row. This example is part of a larger example available in the VirtualMode reference topic.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top