EditPoint2.AbsoluteCharOffset 屬性
取得從文件開頭到 EditPoint2 物件的字元位移 (以 1 為起始)。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
ReadOnly Property AbsoluteCharOffset As Integer
int AbsoluteCharOffset { get; }
property int AbsoluteCharOffset {
int get ();
}
abstract AbsoluteCharOffset : int with get
function get AbsoluteCharOffset () : int
屬性值
類型:Int32
從文件開頭到 EditPoint2 物件的字元位移 (以 1 為起始)。
備註
AbsoluteCharOffset 傳回從文件頂端到物件的字元數,與其相較之下,LineCharOffset 屬性所決定的字元數則只是從包含物件的那一行開頭算起。
警告
所有新行字元或因為此屬性而作為單一字元的序列計數。例如,Visual Basic 中以 vbCrLf(歸位字元+換行) 代表的新行算單一字元。
字元編號從 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。