DataRowView.CancelEdit Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Cancels an edit procedure.
public:
virtual void CancelEdit();
public void CancelEdit ();
abstract member CancelEdit : unit -> unit
override this.CancelEdit : unit -> unit
Public Sub CancelEdit ()
Implements
Examples
The following example edits a row in a DataView. The CancelEdit method is called to cancel the changes if the validation fails.
private void EditDataRowView(DataRowView rowView,
string columnToEdit)
{
rowView.BeginEdit();
rowView[columnToEdit] = textBox1.Text;
// Validate the input with a function.
if (ValidateCompanyName(rowView[columnToEdit]))
rowView.EndEdit();
else
rowView.CancelEdit();
}
private bool ValidateCompanyName(object valuetoCheck)
{
// Insert code to validate the value.
return true;
}
Private Sub EditDataRowView(rowView As DataRowView, _
columnToEdit As String)
rowView.BeginEdit()
rowView(columnToEdit) = textBox1.Text
' Validate the input with a function.
If ValidateCompanyName(rowView(columnToEdit)) Then
rowView.EndEdit()
Else
rowView.CancelEdit()
End If
End Sub
Private Function ValidateCompanyName( _
valuetoCheck As Object) As Boolean
' Insert code to validate the value.
Return True
End Function
Remarks
After calling CancelEdit, all changes to the row are rolled back. You can also roll back changes by calling RejectChanges on the parent DataTable.
Applies to
See also
Samarbejd med os på GitHub
Kilden til dette indhold kan findes på GitHub, hvor du også kan oprette og gennemse problemer og pullanmodninger. Du kan få flere oplysninger i vores vejledning til bidragydere.
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om