DataRow.EndEdit Método

Definição

Finaliza a edição que ocorre na linha.

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

Exceções

O método foi chamado dentro do evento RowChanging.

A edição violou uma restrição.

A linha pertence à tabela e a edição tentou alterar o valor de uma coluna somente leitura.

A edição tentou colocar um valor nulo em uma coluna em que AllowDBNull é false.

Exemplos

O exemplo a seguir usa o EndEdit método para encerrar a edição de um DataRow valor se a função de validação retornar 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

Comentários

Quando você define a propriedade, uma exceção será gerada se uma exceção ocorrer no evento RowChanging.

Aplica-se a

Confira também