This documentation is archived and is not being maintained.

TextPoint Object

Visual Studio .NET 2003

Represents a location of text in a text document.






[Visual Basic .NET]
Public Interface TextPoint
    Inherits IDispatch
[Visual Basic 6]
Class TextPoint
interface TextPoint : IDispatch
public interface TextPoint : IDispatch
[JScript .NET]
public interface TextPoint extends IDispatch


The TextPoint object allows you to find locations in a document. Using the properties of the TextPoint object, you can find text with:

  • Line numbers.
  • Character numbers in a line.
  • Absolute character locations from the beginning of the document.
  • Display columns.

TextPoint objects are similar to EditPoint Objects, except that they operate on text displayed in a code editor rather than data in the text buffer. The difference is that text in a document is affected by global editor states, such as word wrapping and virtual spaces, but the text buffer is not.

As you edit a document, TextPoint objects do not move relative to their surrounding text. That is, if text is inserted before a text point, then the value of its AbsoluteCharOffset Property is incremented to reflect its new location further down in the document. If multiple TextPoint objects are at the same location and an EditPoint object is used to insert new text, then the new characters will be to the right of all of the TextPoint objects except the one used to insert the text.

Any operation that attempts to modify a TextDocument Object will fail if the TextDocument is read-only.


Namespace: EnvDTE

File: dte.tlb


Sub TextPointExample()
   'Comments a region of code.
   Dim selection As TextSelection
   selection = dte.ActiveDocument.selection()
   Dim Start As Editpoint
   Start = selection.TopPoint.CreateEditPoint()
   Dim endpt As TextPoint
   endpt = selection.BottomPoint
   Dim undoObj As UndoContext = dte.UndoContext
   undoobj.Open("Comment Region")
   Do While (Start.LessThan(endpt))
End Sub

See Also

Properties, Events, and Methods | EditPoint Object | CreateEditPoint Method (General Extensibility)