EditPoint.AbsoluteCharOffset Property
Visual Studio 2012
Gets the one-based character offset of the EditPoint object.
Namespace: EnvDTE
Assembly: EnvDTE (in EnvDTE.dll)
AbsoluteCharOffset returns the number of characters from the top of the document to the object. The LineCharOffset property determines the number of characters only from the beginning of the line containing the object. New line characters count as one character.
Character numbering begins at one.
public void AbsoluteCharOffsetExample(DTE2 dte) { // Create a new text file. dte.ItemOperations.NewFile(@"General\Text File", "", Constants.vsViewKindPrimary); // Create an EditPoint at the start of the new document. TextDocument doc = (TextDocument)dte.ActiveDocument.Object("TextDocument"); EditPoint point = doc.StartPoint.CreateEditPoint(); // Insert 10 lines of text. for (int i = 1; i <= 10; ++i) point.Insert("This is a test.\n"); // Display EditPoint properties. MessageBox.Show( "AbsoluteCharOffset: " + point.AbsoluteCharOffset + "\n" + "AtEndOfDocument: " + point.AtEndOfDocument + "\n" + "AtEndOfLine: " + point.AtEndOfLine + "\n" + "AtStartOfDocument: " + point.AtStartOfDocument + "\n" + "AtStartOfLine: " + point.AtStartOfLine); }
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.