UndoContext.Close 方法
结束撤消操作。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
Sub Close
void Close()
void Close()
abstract Close : unit -> unit
function Close()
备注
如果有对 UndoContext 对象的挂起引用,则 Close 中止该操作并引发一个错误。 调用 Close 时,如果 UndoContext 对象未打开,则将出现错误。
示例
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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。