Export (0) Print
Expand All

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. 
        this.customers.RemoveAt(e.Row.Index);
    }

    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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft