Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
IsOpen Property (General Extensibility)
ID
Top
Collapse the table of content
Expand the table of content

IsOpen Property (General Extensibility)

Visual Studio .NET 2003

Determines if an undo operation is currently in effect or if a solution is open.

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

Return Value

True if an undo operation is in effect or if a solution is open, False if not.

Remarks

An undo operation is in effect if the UndoContext object is open.

An open solution does not necessarily have a solution (.sln) file, because it might not have been saved yet.

Example

This example removes all newline characters from a block of selected text:

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

See Also

AddFromFile Method (Solution Object) | AddFromTemplate Method (Solution Object) | Open Method (General Extensibility) | Saved Property (General Extensibility) | IsAborted Property | Open Method (UndoContext Object)

Applies To: Solution Object | UndoContext Object

Show:
© 2015 Microsoft