DataGridViewRowCancelEventArgs.Row Property


Gets the row that the user is deleting.

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

public DataGridViewRow Row { get; }

Property Value

Type: System.Windows.Forms.DataGridViewRow

The row that the user deleted.

The following code example illustrates the use of this type. This example is part of a larger example available in How to: Implement Virtual Mode in the Windows Forms DataGridView Control.

private void dataGridView1_UserDeletingRow(object sender,
    System.Windows.Forms.DataGridViewRowCancelEventArgs e)
    if (e.Row.Index < this.customers.Count)
        // If the user has deleted an existing row, remove the 
        // corresponding Customer object from the data store.

    if (e.Row.Index == this.rowInEdit)
        // If the user has deleted a newly created row, release
        // the corresponding Customer object. 
        this.rowInEdit = -1;
        this.customerInEdit = null;

.NET Framework
Available since 2.0
Return to top