共用方式為


EditPoint.AbsoluteCharOffset 屬性

取得 EditPoint 物件的字元位移 (Offset),以 1 起始。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property AbsoluteCharOffset As Integer
    Get
int AbsoluteCharOffset { get; }
property int AbsoluteCharOffset {
    int get ();
}
abstract AbsoluteCharOffset : int
function get AbsoluteCharOffset () : int

屬性值

型別:System.Int32
從文件開頭 (以 1 起始) 到 EditPoint 物件的字元位移。

實作

TextPoint.AbsoluteCharOffset

備註

AbsoluteCharOffset 傳回從文件頂端到物件的字元數目。 LineCharOffset 屬性僅從包含物件那行的開頭決定字元數目。 新行字元也會計算為一個字元。

字元編號從 1 開始。

範例

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 安全性

請參閱

參考

EditPoint 介面

AbsoluteCharOffset 多載

EnvDTE 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例