Bookmark.SelectionChange 事件

Bookmark 控件中的所选内容更改时发生。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
Event SelectionChange As SelectionEventHandler
event SelectionEventHandler SelectionChange

备注

此事件在所选内容更改为 Bookmark 控件,或当所选内容位于该控件中时引发。

示例

下面的代码示例向文档中添加一个带有文本的 Bookmark 控件,然后创建一个 SelectionChange 事件处理程序。 当在该书签内移动光标时,会显示一个消息框。

此示例针对的是文档级自定义项。

WithEvents Bookmark5 As Microsoft.Office.Tools.Word.Bookmark

Private Sub BookmarkSelectionChange()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Bookmark5 = Me.Controls.AddBookmark(Me.Paragraphs(1).Range, _
        "Bookmark5")
    Bookmark5.Text = "This is a sample bookmark."
End Sub

Private Sub Bookmark5_SelectionChange(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.SelectionEventArgs) _
    Handles Bookmark5.SelectionChange
    MessageBox.Show("The selection has changed within Bookmark1.")
End Sub
Microsoft.Office.Tools.Word.Bookmark bookmark5;

private void BookmarkSelectionChange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    bookmark5 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark5");
    bookmark5.Text = "This is a sample bookmark.";
    bookmark5.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(bookmark5_SelectionChange);
}

void bookmark5_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    MessageBox.Show("The selection has changed within bookmark1.");
}

.NET Framework 安全性

请参见

参考

Bookmark 接口

Microsoft.Office.Tools.Word 命名空间