Bookmark.Deselected 事件

會在選取範圍從 Bookmark 控制項移至 Bookmark 控制項以外的區域時發生。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
Event Deselected As SelectionEventHandler
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");
}

.NET Framework 安全性

請參閱

參考

Bookmark 介面

Microsoft.Office.Tools.Word 命名空間