EditPoint2.AbsoluteCharOffset 属性
获取文档开头到 EditPoint2 对象的字符偏移量,从 1 开始。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
ReadOnly Property AbsoluteCharOffset As Integer
int AbsoluteCharOffset { get; }
property int AbsoluteCharOffset {
int get ();
}
abstract AbsoluteCharOffset : int
function get AbsoluteCharOffset () : int
属性值
类型:System.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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。