_DTE.UndoContext Property

Definition

Gets the global UndoContext object.

C++/CX
public:
 property EnvDTE::UndoContext ^ UndoContext { EnvDTE::UndoContext ^ get(); };

Property Value

A UndoContext object.

Attributes

Examples

VB
Sub UndoContextExample()  
   Dim selection As TextSelection = DTE.ActiveDocument.Selection()  
   Dim start As EditPoint = selection.TopPoint.CreateEditPoint()  
   Dim endpt As TextPoint = selection.BottomPoint  
   Dim commentStart As String  

   DTE.UndoContext.Open("Comment Region")  
   Try  
      Do While (start.LessThan(endpt))  
         start.Insert(commentStart)  
         start.LineDown()  
         start.StartOfLine()  
      Loop  
   Finally  
      ' If an error occured, then need to make sure that the undo   
      ' context is cleaned up. Otherwise, the editor can be left in a   
      ' perpetual undo context.  
      DTE.UndoContext.Close()  
   End Try  
End Sub  

Applies to

Proizvod Verzije
Visual Studio SDK 2015, 2017, 2019