DataRow.EndEdit Método

Definición

Finaliza la edición que se está produciendo en la fila.

public:
 void EndEdit();
public void EndEdit ();
member this.EndEdit : unit -> unit
Public Sub EndEdit ()

Excepciones

Se ha llamado al método dentro del evento RowChanging.

Restricción interrumpida por la edición.

La fila pertenece a la tabla y la edición ha intentado cambiar el valor de una columna de sólo lectura.

La edición ha intentado colocar un valor nulo en una columna donde AllowDBNull es false.

Ejemplos

En el ejemplo siguiente se usa el método para finalizar la EndEdit edición de un DataRow valor si la función de validación devuelve true.

private void AcceptOrReject(DataRow row)
{
    // Use a function to validate the row's values.
    // If the function returns true, end the edit;
    // otherwise cancel it.
    if(ValidateRow(row))
        row.EndEdit();
    else
        row.CancelEdit();
}

private bool ValidateRow(DataRow thisRow)
{
    bool isValid = true;
    // Insert code to validate the row values.
    // Set the isValid variable.
    return isValid;
}
 Private Sub AcceptOrReject(ByVal row As DataRow)
    ' Use a function to validate the row's values.
    ' If the function returns true, end the edit; 
    ' otherwise cancel it.
    If ValidateRow(row) Then
       row.EndEdit()
    Else
       row.CancelEdit()
    End If
End Sub
 
Private Function ValidateRow(ByVal row As DataRow) As Boolean
    Dim isValid As Boolean
    ' Insert code to validate the row values. 
    ' Set the isValid variable.
    ValidateRow = isValid
End Function

Comentarios

Al establecer la propiedad , se genera una excepción si se produce una excepción en el RowChanging evento .

Se aplica a

Consulte también