DataTable.RejectChanges Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Restaure toutes les modifications apportées à la table depuis son chargement, ou la dernière fois AcceptChanges() qu’elle a été appelée.
public:
void RejectChanges();
public void RejectChanges();
member this.RejectChanges : unit -> unit
Public Sub RejectChanges ()
Exemples
L’exemple suivant apporte plusieurs modifications à un DataTable, mais rejette les modifications en appelant la RejectChanges méthode.
private void ShowRejectChanges(DataTable table)
{
// Print the values of row 1, in the column named "CompanyName."
Console.WriteLine(table.Rows[1]["CompanyName"]);
// Make Changes to the column named "CompanyName."
table.Rows[1]["CompanyName"] = "Taro";
// Reject the changes.
table.RejectChanges();
// Print the original values:
Console.WriteLine(table.Rows[1]["CompanyName"]);
}
Private Sub ShowRejectChanges(table As DataTable)
' Print the values of row 1, in the column named "CompanyName."
Console.WriteLine(table.Rows(1)("CompanyName"))
' Make Changes to the column named "CompanyName."
table.Rows(1)("CompanyName") = "Taro"
' Reject the changes.
table.RejectChanges()
' Print the original values:
Console.WriteLine(table.Rows(1)("CompanyName"))
End Sub
Remarques
Lorsqu’il RejectChanges est appelé, tous les DataRow objets qui sont toujours en mode édition annulent leurs modifications. Les nouvelles lignes sont supprimées. Lignes avec la DataRowState valeur Modified définie ou Deleted revenez à leur état d’origine.