EditPoint.ReadOnly Method (Object)

 

Returns a value indicating whether any of the specified range contains read-only text.

Namespace:   EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

bool ReadOnly(
	object PointOrCount
)

Parameters

PointOrCount
Type: System.Object

Required. Either a TextPoint object or a number of characters.

Return Value

Type: System.Boolean

true if the selection contains read-only text; otherwise, false.

A character can be read-only if the entire document is marked as such, or if the character is contained in a read-only block.

Sub ReadOnlyExample()
   Dim objTextDoc As TextDocument
   Dim objMovePt As EditPoint
   Dim objEditPt As EditPoint, iCtr As Integer

   ' Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")

   ' Get a handle to the new document and create an EditPoint.
   objTextDoc = DTE.ActiveDocument.Object("TextDocument")
   objEditPt = objTextDoc.StartPoint.CreateEditPoint
   objMovePt = objTextDoc.EndPoint.CreateEditPoint

   ' Insert ten lines of text.
   For iCtr = 1 To 10
      objEditPt.Insert("This is a test." & Chr(13))
   Next iCtr
   ' Move the active point to where the second edit point is
   ' and then insert some text.
   MsgBox("Is text read-only? " & objEditPt.ReadOnly(5))
End Sub
Return to top
Show: