Partager via


UndoContext.Close, méthode

Termine une opération d'annulation.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
Sub Close
void Close()
void Close()
abstract Close : unit -> unit 
function Close()

Notes

Si des références à l'objet UndoContext sont en attente, la méthode Close abandonne l'opération et déclenche une erreur. Une erreur se produit si la méthode Close est appelée alors que l'objet UndoContext n'est pas ouvert.

Exemples

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

   ' Check to see if UndoContext object is already open.
   If DTE.UndoContext.IsOpen = True Then
      boolWasOpen = True
   Else
      ' Open the UndoContext object to track changes.
      DTE.UndoContext.Open("RemoveNewLines", False)
   End If

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

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

Sécurité .NET Framework

Voir aussi

Référence

UndoContext Interface

EnvDTE, espace de noms