EditPoint2.SetBookmark 方法
在缓冲区中的当前行上设置未命名的书签。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
Sub SetBookmark
void SetBookmark()
void SetBookmark()
abstract SetBookmark : unit -> unit
function SetBookmark()
示例
Sub SetBookmarkExample(ByVal dte As DTE2)
' Create a new text document.
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 ten lines of text.
For i = 1 To 10
point.Insert("This is a test." & vbCrLf)
Next
point.StartOfDocument()
' Set a bookmark on each of the first two lines.
point.SetBookmark()
point.LineDown(1)
point.SetBookmark()
' Insert text at each bookmark and then clear each bookmark.
point.PreviousBookmark()
point.Insert("BOOKMARK 1: ")
point.ClearBookmark()
point.NextBookmark()
point.Insert("BOOKMARK 2: ")
point.ClearBookmark()
End Sub
public void SetBookmarkExample(DTE2 dte)
{
// Create a new text document.
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 ten lines of text.
for (int i = 1; i <= 10; ++i)
point.Insert("This is a test.\n");
point.StartOfDocument();
// Set a bookmark on each of the first two lines.
point.SetBookmark();
point.LineDown(1);
point.SetBookmark();
// Insert text at each bookmark and then clear each bookmark.
point.PreviousBookmark();
point.Insert("BOOKMARK 1: ");
point.ClearBookmark();
point.NextBookmark();
point.Insert("BOOKMARK 2: ");
point.ClearBookmark();
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。