DataGridViewRowCancelEventArgs Class

Definition

Provides data for the UserDeletingRow event of a DataGridView.

public class DataGridViewRowCancelEventArgs : System.ComponentModel.CancelEventArgs
Inheritance
DataGridViewRowCancelEventArgs

Examples

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;
    }
}

Remarks

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

For more information about how to handle events, see Handling and Raising Events.

Constructors

Properties

Cancel

Gets or sets a value indicating whether the event should be canceled.

(Inherited from CancelEventArgs)
Row

Gets the row that the user is deleting.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also