Bookmark.Deselected 事件 (2007 system)

更新:2007 年 11 月

当选择从 Bookmark 控件移到 Bookmark 控件之外的某个区域时发生。

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

语法

声明
Public Event Deselected As SelectionEventHandler
用法
Dim instance As Bookmark
Dim handler As SelectionEventHandler

AddHandler instance.Deselected, handler
public event SelectionEventHandler Deselected

备注

仅当 Bookmark 控件具有焦点,然后将焦点移出 Bookmark 控件时,才引发此事件。

示例

下面的代码示例向文档的第一个段落添加一个带有文本的 Bookmark 控件,并创建一个 Deselected 事件处理程序。当用户将光标从书签内移到书签外的某个区域时,会显示一个消息框。

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

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

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

Private Sub BookmarkDeselect_Deselected(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.SelectionEventArgs) _
    Handles BookmarkDeselect.Deselected
    MessageBox.Show("The selection has moved outside of the bookmark")
End Sub
Microsoft.Office.Tools.Word.Bookmark bookmarkDeselect;

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

void  bookmarkDeselect_Deselected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    MessageBox.Show("The selection has moved outside of the bookmark");
}

权限

另请参见

参考

Bookmark 类

Bookmark 成员

Microsoft.Office.Tools.Word 命名空间