Partager via


EditPoint2.AbsoluteCharOffset, propriété

Obtient l'offset du caractère de base 1 entre le début du document et l'objet EditPoint2.

Espace de noms :  EnvDTE80
Assembly :  EnvDTE80 (dans EnvDTE80.dll)

Syntaxe

'Déclaration
ReadOnly Property AbsoluteCharOffset As Integer
    Get
int AbsoluteCharOffset { get; }
property int AbsoluteCharOffset {
    int get ();
}
abstract AbsoluteCharOffset : int
function get AbsoluteCharOffset () : int

Valeur de propriété

Type : System.Int32
Offset du caractère de base 1 entre le début du document et l'objet EditPoint2.

Implémentations

EditPoint.AbsoluteCharOffset

Notes

AbsoluteCharOffset retourne le nombre de caractères entre le haut du document et l'objet, par comparaison à la propriété LineCharOffset qui détermine le nombre de caractères uniquement depuis le début de la ligne qui contient l'objet.

Avertissement

Tous les caractères ou séquences de saut de ligne comptent comme caractère unique dans le cadre de cette propriété. Par exemple, le saut de ligne désigné dans Visual Basic par vbCrLf (retour chariot + saut de ligne) compte comme un caractère unique.

La numérotation des caractères débute à 1.

Exemples

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);
}

Sécurité .NET Framework

Voir aussi

Référence

EditPoint2 Interface

AbsoluteCharOffset, surcharge

EnvDTE80, espace de noms

Autres ressources

Comment : compiler et exécuter les exemples de code du modèle objet Automation