다음을 통해 공유


UndoContext.Close 메서드

실행 취소 작업을 끝냅니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Sub Close
void Close()
void Close()
abstract Close : unit -> unit
function Close()

설명

UndoContext 개체에 대해 보류 중인 참조가 있는 경우 Close는 작업을 중단하고 오류를 발생시킵니다. UndoContext 개체가 열려 있지 않은 상태에서 Close를 호출하면 오류가 발생합니다.

예제

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

.NET Framework 보안

참고 항목

참조

UndoContext 인터페이스

EnvDTE 네임스페이스