DataGridViewRowCancelEventArgs Clase

Definición

Proporciona datos para el evento UserDeletingRow de DataGridView.Provides data for the UserDeletingRow event of a DataGridView.

public ref class DataGridViewRowCancelEventArgs : System::ComponentModel::CancelEventArgs
public class DataGridViewRowCancelEventArgs : System.ComponentModel.CancelEventArgs
type DataGridViewRowCancelEventArgs = class
    inherit CancelEventArgs
Public Class DataGridViewRowCancelEventArgs
Inherits CancelEventArgs
Herencia
DataGridViewRowCancelEventArgs

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este tipo.The following code example illustrates the use of this type. Este ejemplo forma parte de un ejemplo más grande disponible en cómo: Implemente el modo virtual en el controlDataGridView Windows Forms.This example is part of a larger example available in How to: Implement Virtual Mode in the Windows Forms DataGridView Control.

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 = nullptr;
   }
}
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;
    }
}
Private Sub dataGridView1_UserDeletingRow(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) _
    Handles dataGridView1.UserDeletingRow

    If e.Row.Index < Me.customers.Count Then

        ' If the user has deleted an existing row, remove the 
        ' corresponding Customer object from the data store.
        Me.customers.RemoveAt(e.Row.Index)

    End If

    If e.Row.Index = Me.rowInEdit Then

        ' If the user has deleted a newly created row, release
        ' the corresponding Customer object. 
        Me.rowInEdit = -1
        Me.customerInEdit = Nothing

    End If

End Sub

Comentarios

Para cancelar la eliminación de una fila en un UserDeletingRow controlador de eventos, establezca Cancel la propiedad trueen.To cancel the deletion of a row in a UserDeletingRow event handler, set the Cancel property to true.

Para obtener más información acerca de cómo controlar eventos, vea controlar y provocar eventos.For more information about how to handle events, see Handling and Raising Events.

Constructores

DataGridViewRowCancelEventArgs(DataGridViewRow)

Inicializa una nueva instancia de la clase DataGridViewRowCancelEventArgs.Initializes a new instance of the DataGridViewRowCancelEventArgs class.

Propiedades

Cancel

Obtiene o establece un valor que indica si se debe cancelar el evento.Gets or sets a value indicating whether the event should be canceled.

(Heredado de CancelEventArgs)
Row

Obtiene la fila que elimina el usuario.Gets the row that the user is deleting.

Métodos

Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Heredado de Object)
GetHashCode()

Sirve como función hash predeterminada.Serves as the default hash function.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Heredado de Object)
ToString()

Devuelve un valor de tipo string que representa el objeto actual.Returns a string that represents the current object.

(Heredado de Object)

Se aplica a

Consulte también: