Share via


EditPoint.PreviousBookmark 方法

将编辑点移动到文档中的上一个书签位置。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Function PreviousBookmark As Boolean
bool PreviousBookmark()
bool PreviousBookmark()
abstract PreviousBookmark : unit -> bool
function PreviousBookmark() : boolean

返回值

类型:Boolean
一个布尔值,如果编辑点移动到上一个书签,则为 true;否则为 false。

备注

如果没有其他书签,则不移动编辑点。

PreviousBookmark 将 EditPoint 对象移动到位于 EditPoint 活动端点位置之前的第一个书签的位置。 EditPoint 在新位置折叠。

示例

Sub PreviousBookmarkExample(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 PreviousBookmarkExample(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 安全性

请参阅

参考

EditPoint 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例