DataGridViewRowCancelEventArgs Class
Collapse the table of content
Expand the table of content

DataGridViewRowCancelEventArgs Class

Provides data for the UserDeletingRow event of a DataGridView.

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

public class DataGridViewRowCancelEventArgs : CancelEventArgs

To cancel the deletion of a row in a UserDeletingRow event handler, set the Cancel property to true.

For more information about handling events, see Consuming Events.

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;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

© 2015 Microsoft