EditPoint2.AbsoluteCharOffset Property
Gets the one-based character offset from the beginning of the document to the EditPoint2 object.
Namespace: EnvDTE80
Assembly: EnvDTE80 (in EnvDTE80.dll)
Syntax
'Declaration
ReadOnly Property AbsoluteCharOffset As Integer
'Usage
Dim instance As EditPoint2
Dim value As Integer
value = instance.AbsoluteCharOffset
int AbsoluteCharOffset { get; }
property int AbsoluteCharOffset {
int get ();
}
function get AbsoluteCharOffset () : int
Property Value
Type: System.Int32
The one-based character offset from the beginning of the document to the EditPoint2 object.
Implements
Remarks
AbsoluteCharOffset returns the number of characters from the top of the document to the object, as compared to the LineCharOffset property, which determines the number of characters only from the beginning of the line that contains the object. New line characters count as one character.
Warning
All newline characters or sequences count as a single character for the purposes of this property. For example, the newline denoted in Visual Basic by vbCrLf (carriage return + line feed) counts as a single character.
Character numbering begins at one.
Examples
Sub AbsoluteCharOffsetExample(ByVal dte As DTE2)
' Create a new text file.
dte.ItemOperations.NewFile()
' Create an EditPoint at the start of the new document.
Dim doc As TextDocument = _
CType(dte.ActiveDocument.Object("TextDocument"), TextDocument)
Dim point As EditPoint = doc.StartPoint.CreateEditPoint
Dim i As Integer
' Insert 10 lines of text.
For i = 1 To 10
point.Insert("This is a test." & vbCrLf)
Next
' Display EditPoint properties.
MsgBox( _
"AbsoluteCharOffset: " & point.AbsoluteCharOffset & vbCrLf & _
"AtEndOfDocument: " & point.AtEndOfDocument & vbCrLf & _
"AtEndOfLine: " & point.AtEndOfLine & vbCrLf & _
"AtStartOfDocument: " & point.AtStartOfDocument & vbCrLf & _
"AtStartOfLine: " & point.AtStartOfLine)
End Sub
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);
}
.NET Framework Security
- 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.
See Also
Reference
Other Resources
How to: Compile and Run the Automation Object Model Code Examples