UndoContext.SetAborted Methode

Definition

Verwirft alle Änderungen an teilnehmenden geöffneten Dokumenten, seitdem das UndoContext-Objekt geöffnet wurde.Discards all changes to participating open documents since opening the UndoContext object.

public:
 void SetAborted();
public:
 void SetAborted();
void SetAborted();
[System.Runtime.InteropServices.DispId(5)]
public void SetAborted ();
[<System.Runtime.InteropServices.DispId(5)>]
abstract member SetAborted : unit -> unit
Public Sub SetAborted ()
Attribute

Beispiele

Sub SetAbortedExample()  
   ' Before running, select text in an open document.  
   Dim txtSel As TextSelection  
   Dim strTS As String, strAnswer As String, bIsOpen As Boolean  
   txtSel = DTE.ActiveDocument.Selection  
   strTS = txtSel.Text  

   ' Check to see if UndoContext object is already open.  
   If DTE.UndoContext.IsOpen = True Then  
      bIsOpen = True  
   Else  
      ' Open the UndoContext object to track changes.  
      DTE.UndoContext.Open("RemoveNewLines", False)  
   End If  
   MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)  

   ' Perform search for newline characters and remove them.  
   If strTS <> "" Then  
      txtSel.Delete()  
      strTS = Replace(strTS, vbNewLine, "", Compare:=vbTextCompare)  
      txtSel.Insert(strTS)  
   End If  

   ' Check to see if you want to discard changes.  
   strAnswer = MsgBox("Do you want to discard all changes made?", vbYesNo & vbQuestion)  
   If strAnswer = True Then  
      DTE.UndoContext.SetAborted()  
      MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)  
   End If  

   ' If UndoContext was already open, don't close it.  
   If bIsOpen = True Then  
      ' Close the UndoContext object to commit the changes.  
      DTE.UndoContext.Close()  
   End If  
End Sub  

Hinweise

SetAborted legt die- IsAborted Eigenschaft für das geöffnete UndoContext Objekt auf fest true .SetAborted sets the IsAborted property for the open UndoContext object to true. In diesem Fall werden alle Änderungen, die an den teilnehmenden Dokumenten seit dem Öffnen des-Objekts vorgenommen wurden, UndoContext bis zum Schließen des- UndoContext Objekts verworfen.When this occurs, all changes made to participating documents since opening the UndoContext object until the UndoContext object is closed are discarded.

Gilt für: