共用方式為


UndoContext.IsAborted 屬性

取得 UndoContext 物件操作是否為 SetAborted 方法所終止。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property IsAborted As Boolean
bool IsAborted { get; }
property bool IsAborted {
    bool get ();
}
abstract IsAborted : bool with get
function get IsAborted () : boolean

屬性值

類型:Boolean
如果作業被中止,布林值會指示 true,否則,會指示 false。

備註

如果 UndoContext 物件在關閉前已經被 SetAborted 所停用,則針對參與文件進行的所有變更會在 UndoContext 物件關閉時被捨棄。

範例

Sub IsAbortedExample()
   ' 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

.NET Framework 安全性

請參閱

參考

UndoContext 介面

EnvDTE 命名空間