This documentation is archived and is not being maintained.

UndoContext Property (DTE Object)

Visual Studio .NET 2003

Returns the global UndoContext Object.

[Visual Basic .NET]
Public ReadOnly Property UndoContext() As UndoContext
[Visual Basic 6]
Property Get UndoContext() As UndoContext
[C++]
HRESULT __stdcall get_UndoContext(
   /* [out, retval] */ UndoContext** retVal
);
[C#]
public UndoContext UndoContext {get;}
[JScript .NET]
public function get UndoContext() : UndoContext

Return Value

Returns a UndoContext object.

Example

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

See Also

UndoContext Object

Applies To: DTE Object

Show: